先下载升级包:https://pan.baidu.com/s/1hsitVda
关闭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/local/ --enable-safe-mode -enable-fastcgi -enable-force-cgi-redirect --with-gd --with-jpeg-dir=/usr/local/ --with-png-dir=/usr/local/ --enable-sockets --with-mysqli=mysqlnd --with-openssl --enable-soap --enable-mbstring --enable-mbregex --enable-sqlite-utf8 --enable-zip --with-freetype-dir=/usr/local/ --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配置或者文件权限问题
附上:nginx标准配置
server { listen 8117; server_name localhost; charset utf-8; root /home/www/src/kmadadmin/public; index index.php; location / { if (!-e $request_filename) { rewrite ^(.*)$ /index.php$1 last; break; } } location ~ \.php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /home/www/src/kmadadmin/public/$fastcgi_script_name; include fastcgi_params; } location ~ .+\.php($|/) { #配置PHP支持PATH_INFO进行URL重写 set $script $uri; set $path_info "/"; if ($uri ~ "^(.+\.php)(/.+)"){ set $script $1; set $path_info $2; } fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php?IF_REWRITE=1; include fastcgi_params; fastcgi_param SCRIPT_FILENAME /home/www/src/kmadadmin/public/$script; fastcgi_param PATH_INFO $path_info; fastcgi_param SCRIPT_NAME $script; } }
我在升级的时候nginx站点 一直502,最后改了配置文件/usr/local/php/etc/php-fpm.d/www.conf