Press "Enter" to skip to content

WordPress yum升级PHP版本到PHP7.2

说在升级之前的话:升级需谨慎,备份很重要!!!升级前有条件的话先测试下PHP7与主题的兼容性等问题.

主机环境:
[root@test yum.repos.d]# cat /etc/redhat-release
CentOS Linux release 7.4.1708 (Core)
php当前版本:PHP 5.4.16
php升级目标版本:PHP 7.2.4
升级目的:就冲官方文档的一句话"Improved performance: PHP 7 is up to twice as fast as PHP 5.6",这就是升级的动力.
Wordpress环境:LAMP

升级步骤:
再次说明:备份很重要!!!!
配置yum源:
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
查看原来php的安装命令:(我的原来是yum安装的,编译安装升级参考https://www.tracymc.cn/?p=224)
php php-mysql php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-snmp php-soap
卸载旧版本的php:
rpm -e `rpm -qa|grep php`
安装新版本php:
yum install -y php72w php72w-mysql php72w-gd php72w-ldap php72w-odbc php72w-pear php72w-xml php72w-xmlrpc php72w-mbstring php72w-snmp
查看httpd是否加载了PHP7模块:
[root@test logs]# ll /etc/httpd/modules/|grep php
-rwxr-xr-x 1 root root 5124520 Mar 30 16:59 libphp7.so
-rwxr-xr-x 1 root root 5314192 Mar 30 16:59 libphp7-zts.so
以上说明加载成功.
查看当前版本:
[root@test logs]# php -v
PHP 7.2.4 (cli) (built: Mar 30 2018 08:49:13) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
修改php配置文件:
yum安装默认配置文件路径为/etc/php.ini,具体配置修改可参考原来的配置文件.
重启httpd服务:
systemctl restart httpd
最后检查网站是否正常,样式、主题是否兼容.

Be First to Comment

发表评论

电子邮件地址不会被公开。 必填项已用*标注