• 我们中的有些人,注定要在日常生活的点滴中去寻找生命的意义。---- 《生活大爆炸》|

centos下php多版本共存

Linux admin 2年前 (2018-05-04) 513次浏览 已收录 0个评论

例子:centos下php5.6与php7.2.5多版本共存

1 . 下载PHP

在php官网下载,或 wget http://cn2.php.net/distributions/php-7.2.5.tar.gz

tar -zxvf php-7.2.5.tar.gz

cd php-7.2.5

编译安装:(因为之前装过php所以不用解决依赖关系)

./configure –prefix=/usr/local/php725 –with-config-file-scan-dir=/usr/local/php725/etc/ –enable-inline-optimization –enable-opcache –enable-session –enable-fpm –with-mysql=mysqlnd –with-mysqli=mysqlnd –with-pdo-mysql=mysqlnd –with-pdo-sqlite –with-sqlite3 –with-gettext –enable-mbregex –enable-mbstring –enable-xml –with-iconv –with-mcrypt –with-mhash –with-openssl –enable-bcmath –enable-soap –with-xmlrpc –with-libxml-dir –enable-pcntl –enable-shmop –enable-sysvmsg –enable-sysvsem –enable-sysvshm –enable-sockets –with-curl –with-curlwrappers –with-zlib –enable-zip –with-bz2 –with-gd –enable-gd-native-ttf –with-jpeg-dir –with-png-dir –with-freetype-dir –with-iconv-dir –with-fpm-user=www –with-fpm-group=www

(中路径/usr/local/php725为当前php安装目录,可替换)

make clean && make && make install

 

(注:如果安装中出现

/root/php-7.2.5/ext/iconv/iconv.c:2579: undefined reference to `libiconv_open’
ext/xmlrpc/libxmlrpc/.libs/encodings.o: In function `convert’:
/root/php-7.2.5/ext/xmlrpc/libxmlrpc/encodings.c:65: undefined reference to `libiconv_open’
/root/php-7.2.5/ext/xmlrpc/libxmlrpc/encodings.c:73: undefined reference to `libiconv’
/root/php-7.2.5/ext/xmlrpc/libxmlrpc/encodings.c:93: undefined reference to `libiconv_close’
collect2: ld returned 1 exit status
make: *** [sapi/cli/php] Error 1

这种错误

vim Makefile

添加:-lcrypt

 

 

安装完成之后

cp php-7.2.5/php.ini* /usr/local/php/etc/

cd /usr/local/php/etc/

cp php.ini-production php.ini

cp php-fpm.conf.default php-fpm.conf

cp php-fpm.d/www.conf.default php-fpm.d/http://www.conf(在此文件中修改/tmp/php-cgi725.sock ,php-fpm会在启动时自己生成这个socket文件)

(注可以把此www.conf合并到php-fpm.conf中)

启动php

/usr/local/php725/sbin/php-fpm

在nginx配置中使用PHP7.25

fastcgi_pass unix:/tmp/php-cgi52.sock;


本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:centos下php多版本共存
喜欢 (0)

您必须 登录 才能发表评论!