编译环境和依赖参考:centos6.x编译安装php5.4

这里主要列举一个常用的php-fpm编译参数:

./configure  \
--prefix=/usr/local/php5.4  \
--with-config-file-path=/usr/local/php5.4/etc  \
--with-mysql  \
--with-mysqli  \
--with-iconv-dir=/usr/local/libiconv  \
--with-config-file-scan-dir=/usr/local/php5.4/php.d  \
--with-mhash=/usr  \
--with-icu-dir=/usr  \
--with-bz2  \
--with-curl  \
--with-freetype-dir  \
--with-gd  \
--with-gettext  \
--with-gmp  \
--with-imap  \
--with-imap-ssl  \
--with-jpeg-dir  \
--with-kerberos  \
--with-ldap  \
--with-mcrypt  \
--with-openssl  \
--without-pear  \
--with-pdo-mysql  \
--with-png-dir  \
--with-xmlrpc  \
--with-zlib  \
--enable-bcmath  \
--enable-calendar  \
--enable-ctype  \
--enable-dom  \
--enable-exif  \
--enable-ftp  \
--enable-gd-native-ttf  \
--enable-intl  \
--enable-json  \
--enable-mbstring  \
--enable-pcntl  \
--enable-session  \
--enable-shmop  \
--enable-simplexml  \
--enable-soap  \
--enable-sockets  \
--enable-tokenizer  \
--enable-wddx  \
--enable-xml  \
--enable-zip  \
--disable-fileinfo  \
--enable-fpm

我简单编译php最新版php7.0.6

wget http://cn2.php.net/distributions/php-7.0.6.tar.gz
tar zxvf ./php-7.0.6.tar.gz
cd php-7.0.6

由于php7.0弃用–with-mysql参数,所以这里编译参数里面不加入,否则会出错。

./configure  \
--prefix=/usr/local/php7.0  \
--with-config-file-path=/usr/local/php7.0/etc  \
--with-mysqli  \
--with-iconv-dir=/usr/local/libiconv  \
--with-config-file-scan-dir=/usr/local/php7.0/php.d  \
--with-mhash=/usr  \
--with-icu-dir=/usr  \
--with-bz2  \
--with-curl  \
--with-freetype-dir  \
--with-gd  \
--with-gettext  \
--with-gmp  \
--with-imap  \
--with-imap-ssl  \
--with-jpeg-dir  \
--with-kerberos  \
--with-ldap  \
--with-mcrypt  \
--with-openssl  \
--without-pear  \
--with-pdo-mysql  \
--with-png-dir  \
--with-xmlrpc  \
--with-zlib  \
--enable-bcmath  \
--enable-calendar  \
--enable-ctype  \
--enable-dom  \
--enable-exif  \
--enable-ftp  \
--enable-gd-native-ttf  \
--enable-intl  \
--enable-json  \
--enable-mbstring  \
--enable-pcntl  \
--enable-session  \
--enable-shmop  \
--enable-simplexml  \
--enable-soap  \
--enable-sockets  \
--enable-tokenizer  \
--enable-wddx  \
--enable-xml  \
--enable-zip  \
--disable-fileinfo  \
--enable-fpm

make && make install

1.png

2.png

编译完成后复制php源码目录下 php.ini-production 到php配置目录/usr/local/php7.0/etc/目录下并安你的需求需改php配置文件。

cp php.ini-production /usr/local/php7.0/etc/php.ini

添加php7到服务项并设置自动启动:

cp ./sapi/fpm/init.d.php-fpm /etc/init.d/php7

chmod +x /etc/init.d/php7

chkconfig php7 on

复制php-fpm.conf.default为php-fpm.conf 并按需修改

复制 www.conf.default为www.conf并按需修改

3.png

4.png

由于我环境里面安装过php5.3监听9000端口,所以我修改php7.0为监听9001端口。

5.png

6.png

修改nginx站点使用9001端口处理php程序:

7.png

访问测试:

8.png