php5.6升级到php7.1.10(Linux环境)

环境说明:nginx+php

无需删除旧的php5版本,升级步骤如下:

0、,关闭php-fpm(如果有)
service php-fpm stop


1、拉取php7.1.10 tar包
$wget -c http://php.net/distributions/php-7.1.10.tar.gz -O php-7.1.10.tar.gz


2、解压并进入
$tar -zxvf php-7.1.10.tar.gz 
$cd php-7.1.10


3、编译(参数可以根据需要修改)
$./configure  --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-iconv-dir=/usr --enable-safe-mode -enable-fastcgi -enable-force-cgi-redirect --with-gd --with-jpeg-dir=/usr --with-png-dir=/usr --enable-sockets --with-mysqli=mysqlnd --with-openssl --enable-soap --enable-mbstring --enable-mbregex --enable-sqlite-utf8 --enable-zip --with-freetype-dir=/usr --enable-fpm --with-curl --enable-opcache --with-mcrypt --enable-xml --enable-session --enable-ftp --with-mhash --enable-pcntl --with-gettext --with-gettext --enable-bcmath --with-zlib --with-pdo-mysql --enable-sysvshm --enable-sysvsem --enable-shmop

4、安装
make && make install
(如果提示libiconv模块相关错误,可尝试使用如下命令安装 
$make ZEND_EXTRA_LIBS='-liconv' && make install)


5、修复配置
1)将扩展放到/usr/local/php/lib/php/extensions/no-debug-non-zts-20160303(根据php.ini配置的扩展目录存放)
2)将配置文件放到/usr/local/php/etc
3)nginx下站点配置修改:fastcgi_pass   127.0.0.1:9000;


6、重启验证
service php-fpm restart
service nginx reload 
访问已配置的站点即可
如果出现502 bad gateway 一般都是nginx配置或者文件权限问题


其他注意:
1、php7.1.0以上版本已经废弃了mcrypt扩展的加解密相关函数,如mcrypt_encrypt、mcrypt_get_iv_size、mcrypt_create_iv等,官方:http://php.net/manual/en/function.mcrypt-encrypt.php#117667 
目前有的替换解决方案:使用openssl_encrypt、openssl_decrypt,使用起来更方便简洁,网上解决方案地址:https://www.ctolib.com/topics-122535.html 
记得开启php_openssl扩展

猜你喜欢

转载自my.oschina.net/u/125977/blog/1563174