大网数据广告活动
服务器运维问答

Upgrade PHP 7.0 to 7.2 on Centos

· 52CE 我爱测

I 've a working production server that runs PHP 7.0, and I want to upgrade to 7.2. I haven't found anything online that would suggest that PHP7.0 and 7.2 can co-exist. What would be the proper procedure? Just remove all php70w* p…

问题原文

原帖链接 · Michael Chourdakis · CC BY-SA 3.0

I 've a working production server that runs PHP 7.0, and I want to upgrade to 7.2.

I haven't found anything online that would suggest that PHP7.0 and 7.2 can co-exist. What would be the proper procedure? Just remove all php70w* packages and install all php72w ones?

This is a production server, errors must not cause it to fail.

Thanks.

已采纳解答

原帖链接 · NoAngel · CC BY-SA 3.0

This is solution for CentOS 6.x and 7.x:

yum install epel-release

then install Remi repo, for Centos 6.x:

rpm -Uvh http://rpms.remirepo.net/enterprise/remi-release-6.rpm

and for Centos 7.x:

rpm -Uvh http://rpms.remirepo.net/enterprise/remi-release-7.rpm

check which PHP packages installed:

yum list installed php*

remove current PHP:

yum remove php*

install same packages as were installed for 7.0 using PHP 7.2, for example:

yum install --enablerepo=remi-php72 php php-mcrypt php-cli php-gd php-curl php-mysql php-ldap php-zip php-fileinfo

check version of PHP installed:

php -v

You don't need to PHP 7.0 and 7.2 coexist on Your server. If You got a problem using PHP 7.2 You can always reinstall older PHP 7.0. If not sure it will work for You on production server, try it on virtual machine first. But it worked for me on many production servers. PHP is not critical OS component, so server will never fail if PHP changed. It's just Your web app which may fail when change to 7.2, but as I wrote it's unlikely and You may reinstall older version if it happens.

I forgot about php.ini. If You want to keep Your php.ini customizations in another PHP version, make a copy of php.ini before running yum remove php*. After PHP reinstall diff saved_php.ini php.ini and look what is need to be merged.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2018-03-28)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。