- This guide will UPGRADE PHP5.4 to PHP 5.6, 70, 71 or 7.2, so this isnt side-by-side installation!
- Make full backup of your server and i cant stress enough this part!
- All what you see in this post i tested on my server. If you didnt make some major (deal-breaking) changes it should work without any problem.
- In case you have installed other PHP versions (side-by-side) it would be smart to remove them before proceeding with this guide.
IMPORTANT NOTE # (New):
- I just updated this guide up to PHP 7.2.
- Originally this post was made for PHP 5.6 upgrade but i moved away from this version and now i’m currently testing 7.2.
Details about the upgrade to 7.0, 7.1 and 7.2 can be found at the bottom of this post.
I saw many topics from people asking how to upgrade their Centos 7 native PHP 5.4, or they encountered some problems during/after the upgrade. There are good tutorials how to do this but each one of them was missing something, so i decided to go on my test VPS, check every step of the installation and write it down as simple as i can.
- OS: Centos 7
- PHP: 5.4
- Extra PHP modules: Zend opcache (separate install on PHP 5.4)
- Other PHP versions: None
- Repo needed for this guide: Remi, Epel
Now the tutorial:
1. Disable any extra repository you have installed with
yum-config-manager --disable repository_name, but leave Epel and Remi in case you have it.
2. Update your existing software with
yum updateand press
y + enterwhen asked. After the update run
yum clean all.
3. Install Epel (skip if you already have it):
yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm.
4. Install Remi (skip if you already have it):
yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm.
5. Enable both repos with
yum-config-manager --enable epeland
yum-config-manager --enable remi-php56/php70/php71/php72(use only one, e.g.
yum-config-manager --enable remi-php71).
6. Install “yum-utils”:
yum install yum-utils.
This is the part where i did slightly different then suggested from many guides. Skip steps 7, 8, 9 and 11 if you dont have any obsolete modules or you previously upgraded PHP 5.4 to newer version (must be Remi).
yum check-updateand write down or copy the results. If you have PHP modules that are obsolete i would suggest to remove them with
yum remove php-(e.g.
yum remove php-mysql).
Check-update reported that
php-pecl-zendopcache-7.0.5-1.el7.x86_64are obsolete, other modules will be updated plus some dependencies installed.
8. Write down or copy the results of step 7 so you can later install all missing modules.
9. Restart httpd
systemctl restart httpd.
Now we are going to upgrade PHP to 5.6.
10. Upgrade PHP with
yum updateand press
y + enterwhen asked.
During the upgrade there is a chance you will see messages like
PHP Warning: Module ‘some-PHP-module’ already loaded in Unknown on line 0but they are safe to ignore.
11. Hope you saved the results from step 7 because now we need them. Check what modules were obsolete and removed and now we will bring them back with
yum install php-**(e.g.
yum install php-mysql). Pay attention that some modules could have different names in never PHP versions so you should check (Google or Remi website) before proceeding with this task.
12. Restart httpd
systemctl restart httpd.
yum clean all.
14. Update your phpMyAdmin. Easiest way would be
Virtualmin -> Virtual_server_name -> Install Scripts -> Installed Scriptsand there you will have an option to update your phpMyAdmin. Currently last version is 4.7.4.
After the first upgrade from PHP 5.4 to newer version you will almost certainly have a phpMyAdmin update waiting for you.
find / -name " * .rpmnew"and
find / -name " * .rpmsave"(remove spaces before/after "") and see if anything related to PHP comes out. If there are any
.rpmsavefiles related to PHP you should compare them with the old files and if needed modify them (the old one). Dont forget to run
systemctl restart httpdonce you are done with modifications.
Few test to see if everything works. The results you see are from my test server with PHP 7.2.
[root@##### ~]# php --version
PHP 7.2.0 (cli) (built: Nov 28 2017 20:22:21) ( NTS )
Copyright © 1997-2017 The PHP Group
Zend Engine v3.2.0, Copyright © 1998-2017 Zend Technologies
with Zend OPcache v7.2.0, Copyright © 1999-2017, by Zend Technologies
The status of your system is being checked to ensure that all enabled features are available, that the mail server is properly configured, and that quotas are active …
Apache is installed. The following PHP versions are available : 7.2.0 (/bin/php-cgi)
… your system is ready for use by Virtualmin.
How to upgrade to other PHP versions (7.0, 7.1, 7.2)
19. If this is first upgrade from default PHP 5.4 to 7.0, 7.1 or 7.2 follow all earlier mentioned steps.
20. If you already upgraded PHP 5.4 to never version then skip step 7, 8, 9, 11 and follow the rest.
21. Dont forget to replace
22. Keep in mind that some modules could not be available for PHP 7.*, but if you didnt install anything “exotic” you should be fine.
23. There is a chance you will have some/many deprecated records inside the old *.conf files and you should remove them accordingly.
24. Some preliminary test with Wordpress, Divi theme and PHP 7.2 didnt show any problem, but if you want to play a little safer then go for 7.0 or 7.1.
25. What i saw until now all benchmarks show PHP 7.2 as fastest PHP ever released. If speed is important for you then i would suggest to test it first and if your software/scripts doesnt complain switch to this PHP version. PHP 7.2 is fast, some results show speed increase from 9-10% up to more than 20% compared to 7.0/7.1 and 2x-3x+ better than 5.6.
- Why not side-by-side install?
Because almost everything you have in PHP 5.4 is available in never versions, so i didnt see any point to have multiple PHP versions. Every CMS or software should work 100% up to PHP 7.1 and if it doesnt that means its time to change it for something newer and better maintained.
- How long will my PHP be updated?
PHP 5.6: December 2018
PHP 7.0: December 2017
PHP 7.1: December 2018
PHP 7.2: December 2019
- My PHP isnt working.
At the end of the day its your server and your responsibility to maintain or find someone for this job. Like i mentioned at the beginning of this post i tested each and every step to ensure everything is working. If something went wrong probably you didnt properly follow each step or your server had some other software installed what could be the cause for this installation to fail.
- SAVE!!! the old and new files off-server for the sake of your nerves and health!
I hope you will find this guide useful as i did my best to explain each step and it should be relatively easy to follow. Enjoy your Centos 7 with PHP 5.6, 7.0, 7.1 or 7.2.
Last revision: 30.11.2017.
- Until now i didnt encounter any problem so i can expect that future Remi updates/new versions will follow this trend. Thats why i dont see any reason to continue to update this post and this is my last revision (i hope).