Centos6.9下配置php7.1和php5.4多版本共存

Centos6.9下配置php7.1和php5.4多版本共存

Centos6.9下配置php7.1和php5.4多版本共存"

当前服务器用的是lnmp一键包,已经装好了php7.1,在此基础上,并存一个php5.4的版本。

编译安装php-5.4.45

下载php5.4.45源码包

cd  /usr/src
wget http://cn.php.net/distributions/php-5.4.45.tar.gz
tar zxf php-5.4.45.tar.gz

进入php-5.4.45目录进行编译(注意./configure里指定的路径,当前php-5.6用的/usr/local/php路径,所以我这里就把路径改成了/usr/local/php54路径,避免和php-5.6版本冲突

cd php-5.4.45
./configure --prefix=/usr/local/php54 --with-config-file-path=/usr/local/php54/etc --enable-fpm --with-fpm-user=www --with-fpm-group=www --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-iconv-dir --with-freetype-dir=/usr/local/freetype --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex --enable-mbstring --with-mcrypt --enable-ftp --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --with-gettext --disable-fileinfo --enable-intl --with-xsl
 
make ZEND_EXTRA_LIBS='-liconv'
make install

复制一个php.ini文件

cp php.ini-production /usr/local/php54/etc/php.ini

复制php-fpm启动

cp sapi/fpm/init.d.php-fpm /etc/init.d/php54-fpm
chmod +x /etc/init.d/php54-fpm

修改php-fpm.conf

cd /usr/local/php54/etc/
cp php-fpm.conf.default php-fpm.conf
vim php-fpm.conf

直接将原有php-fpm.conf内容全部删除,复制以下文件

[global]
pid = /usr/local/php54/var/run/php-fpm.pid
error_log = /usr/local/php54/var/log/php-fpm.log
log_level = notice
 
[www]
listen = /tmp/php54-cgi.sock
listen.backlog = -1
listen.allowed_clients = 127.0.0.1:9001
listen.owner = www
listen.group = www
listen.mode = 0666
user = www
group = www
pm = dynamic
pm.max_children = 80
pm.start_servers = 40
pm.min_spare_servers = 40
pm.max_spare_servers = 80
request_terminate_timeout = 100
request_slowlog_timeout = 0
slowlog = var/log/slow.log

启动php54-fpm

/etc/init.d/php54-fpm start

修改nginx配置,配置php

location ~ [^/]\.php(/|$)
{
try_files $uri =404;
fastcgi_pass unix:/tmp/php54-cgi.sock;
fastcgi_index index.php;
include fastcgi.conf;
}

服务器上编辑个phpinfo.php


这个决定启用哪个php 版本

fastcgi_pass unix:/tmp/php54-cgi.sock;


你可能感兴趣的:(Centos6.9下配置php7.1和php5.4多版本共存)