1.卸载旧版本php
首先通过
php -v
命令查看服务器版本号
小编是通过rpm命令手动安装的,所以通过
#rpm -qa|grep php
查看全部的php软件包
可以看到所有的安装包
php-pdo-5.6.4
php-mysql-5.6.4
php-xml-5.6.4
php-cli-5.6.4
php-common-5.6.4
php-gd-5.6.4
依次执行
rpm -e php-mysql-5.6.4
rpm -e php-pdo-5.6.4
rpm -e php-xml-5.6.4
rpm -e php-cli-5.6.4
rpm -e php-gd-5.6.4
rpm -e php-common-5.6.4
进行卸载
注意卸载的顺序
rpm -e php-common-5.6.4
最后执行
再用
php -v
可以看出没有版本号了
不过还有可能存在其他php相关的文件或文件夹
通过
whereis php
查找所有php相关的位置,通过rm -rf 命令进行一个个删除
2.升级安装php
和正常安装php步骤一样
注意编译时添加mysqli扩展
./configure –prefix=/usr/local/php –with-mysqli=mysqlnd –enable-mysqlnd –with-gd –with-openssl –enable-gd-native-ttf –enable-gd-jis-conv –enable-fpm –with-openssl
make && make install
如果提示内存不足,通过kill命令结束掉一些进行
查看进程
ps -A
3.php升级时出现的问题
sudo /usr/local/php/sbin/php-fpm
启动时报错,提示:
[11-Mar-2020 17:58:38] WARNING: Nothing matches the include pattern '/usr/local/php/etc/php-fpm.d/*.conf’ from /usr/local/php/etc/php-fpm.conf at line 125.
[11-Mar-2020 17:58:38] ERROR: No pool defined. at least one pool section must be specified in config file
[11-Mar-2020 17:58:38] ERROR: failed to post process the configuration
[11-Mar-2020 17:58:38] ERROR: FPM initialization failed
解决方法:
cd /usr/local/php/etc/php-fpm.d/
cp www.conf.default www.conf
再执行一遍启动命令运行成功
一切正常后,打开WordPress后台,报错
Fatal error: Uncaught Error: Call to undefined function gzinflate() in /usr/local/nginx/html/
wp-includes/class-requests.php:947 Stack trace: #0 /usr/local/nginx/html/wp-includes/class-requests.php
(886): Requests::compatible_gzinflate('MxC9A x80 x10x05xD0xBBxCC:$x8A …’) #1
/usr/local/nginx/html/wp-includes/class-requests.php(835): Requests::compatible_gzinflate
('x1Fx8Bx08x00x00x00x00x00x00x03MxC9A x80…’) #2 /usr/local/nginx/html/wp-includes/
class-requests.php(675): Requests::decompress('x1Fx8Bx08x00x00x00x00x00x00x03MxC9A x80…’)
#3 /usr/local/nginx/html/wp-includes/class-requests.php(383): Requests::parse_response(Array,
'https://api.wor…’, Array, NULL, Array) #4 /usr/local/nginx/html/wp-includes/class-http.php(393):
Requests::request('https://api.wor…’, Array, NULL, 'GET’, Array) #5 /usr/local/nginx/html/
wp-includes/class-http.php(622): WP_Http->request('https://api.wor…’, Array) #6 /usr/local/nginx
/html/wp-includes/http.php(164): WP_Http->get('https://api.wor…’, Array) #7 in /usr/local/nginx
/html/wp-includes/class-requests.php on line 947
函数未定义,php编译时没有带上zlib扩展
重新编译php的zlib扩展就可以了。
cd /usr/local/src/php-7.2.28/ext/zlib/
cp config0.m4 m4
/usr/local/php/bin/phpize
./configure –with-php-config=/usr/local/php/bin/php-config –with-zlib
make && make install
想了解更多关于php升级过程及出现的常见问题和解决方法的内容,请扫微信
或微信搜索jiemingpan
本文链接:http://www.soufuzi.com/jianzhan/3148