先下載升級包:https://pan.baidu.com/s/1hsitVdaphp
關閉php-fpm(若是有)mysql
service php-fpm stop
一、拉取php7.1.10 tar包nginx
$wget -c http://php.net/distributions/php-7.1.10.tar.gz -O php-7.1.10.tar.gz
二、解壓並進入sql
$tar -zxvf php-7.1.10.tar.gz $cd php-7.1.10
三、編譯bash
$./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
四、安裝session
make && make install
(若是提示libiconv模塊相關錯誤,可嘗試使用以下命令安裝
$make ZEND_EXTRA_LIBS='-liconv' && make install)
五、修復配置
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;
六、重啓驗證php7
service php-fpm restart service nginx reload
訪問已配置的站點便可
若是出現502 bad gateway 通常都是nginx配置或者文件權限問題curl
附上:nginx標準配置socket
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.confphp-fpm