PHP编译安装

php应用编译安装:

  • 安装php5:
# apt-get install gcc libxml2-dev make automake autoconf libtool bison flex
# apt-get install openssl libcurl4-openssl-dev libssl-dev libjpeg-dev libfreetype6-dev libpng12-dev libpcre3 libpcre3-dev build-essential zlib1g-dev
# ln -s /usr/lib/x86_64-linux-gnu/libssl.so  /usr/lib
# wget http://cn2.php.net/distributions/php-5.4.45.tar.gz
# tar -xf php-5.4.45.tar.bz2
# cd php-5.4.45/
# ./configure --prefix=/usr/local/php --with-mysql=/usr/local/mysql --with-config-file-path=/etc/php.ini --with-config-file-scan-dir=/etc/php.d/ --enable-mbstring --enable-ftp --with-gd --with-jpeg-dir=/usr --with-png-dir=/usr --with-mysql=mysqlnd --with-mysqli=/usr/local/mysql/bin/mysql_config --with-openssl-dir=/usr --with-openssl --with-pear --enable-sockets --with-freetype-dir=/usr --enable-gd-native-ttf --with-zlib --with-libxml-dir=/usr --with-xmlrpc --enable-zip --enable-fpm --enable-fpm --enable-xml --enable-sockets --with-gd --with-zlib --with-iconv --enable-zip --with-freetype-dir=/usr/lib/ --enable-soap --enable-pcntl --enable-cli
# make -j 2
# make install
# cd /usr/local/src/php-5.4.45
# cp php.ini-production /usr/local/php/etc/php.ini
# cd /usr/local/php/etc
# cp php-fpm.conf.default php-fpm.conf
# ls -sv /usr/local/php/etc/php.ini /etc/php.ini
  • 测试代码1
<?php
	phpinfo();
?>
  • 测试代码2
<?php header("content-type:text/html; charset=utf-8");?>
<?php
	$connect=mysql_connect("127.0.0.1","root","root");
	if(!$connect) echo "连接失败!";
	else echo "连接成功";
	mysql_close();
?>
  • 开机启动:
# cp /usr/local/php/sbin/php-fpm /etc/init.d/php-fpm
# update-rc.d php-fpm defaults 99
# vim /etc/rc.local
	/etc/init.d/php-fpm
	exit 0
# chmod a+x /etc/rc.local
  • 所遇问题:
1、configure: error: Cannot find OpenSSL's libraries
	find / -name libssl.so
	输出结果为: /usr/lib/x86_64-linux-gnu/libssl.so
	初步判断它可能只会在 /usr/lib/ 下寻找 libssl.so 文件,于是:
	ln -s /usr/lib/x86_64-linux-gnu/libssl.so  /usr/lib
	重新编译安装即通过。
posted @ 2019-04-11 20:35  evescn  阅读(104)  评论(0编辑  收藏  举报