How to install or upgrade to PHP 7 on CentOS 7 Linux Server -

The objective is to install or replace existing PHP 5 with PHP 7 on CentOS 7 Linux server. As you will see, this procedure is fairly simple when using Remi Repository.
This is a companion discussion topic for the original entry at NOTE: SOME OF THE POSTS BELOW ARE TRANSFERRED FROM LINUXCONFIG DISQUS COMMENTS.



Thankkssss so much



Aaaanddd… ERR_CONNECTION_REFUSED after update. :slight_smile:
Any ideas?


Prasenjit Barman

Which versions of PHP can i install in RHEL 6.9


Sławomir Własik

Great article That’s what I was looking for. Thanks


Kiko Seijo

Works like a charm, Grats, so simple,



didn’t work, still shows me php 5.4.16 … doesn’t want to update it and says “already installed and latest version … Nothing to do”


Cristina -> alaadahmed

You have to uninstall php 5.4.16 before doing anything


anonymous -> Cristina

how do you do that? The article starts out “…install or replace existing PHP 5 with PHP 7…”. Wonder why the author did not tell us we needed to uninstall PHP first. To me, replace means, well, replace.


anonymous -> alaadahmed

had the same problem the first time, was because I already had the “EPEL Repository” active. So if u would then copy/past this line “rpm -Uvh remi-release-7.rpm epel-release-latest-7.noarch.rpm” it also did not activate the “Remi Repository”. If u already have the “EPEL Repository” active, use this line “rpm -Uvh remi-release-7.rpm” and after that the php7.0 or php7.1


Phillip Mwaniki -> anonymous

Worked like a charm. Thanks!


can you spell this out further?

If u already have the “EPEL Repository” active, use this line “rpm -Uvh remi-release-7.rpm” and after that the php7.0 or php7.1

what exactly does “and after that the php7.0 or php7.1” mean?



What is meant by that is that you choose which version of PHP 7 you wish to install. Now, there is also a PHP 7.2 available via REMI repository. After you have EPEL and REMI packages installed run one of the following:

# yum-config-manager --enable remi-php70
# yum-config-manager --enable remi-php71
# yum-config-manager --enable remi-php72

Here is a video to show all steps for the entire PHP 7 installation on CentoOS 7:

Hope this helps!



Manually setting up a server with PHP is quite difficult and time taking if you don’t have sysadmin experience. An easier and quick method is to use PaaS, like Cloudways for PHP MySQL hosting. This is because you can launch a server in just one click. The platform automatically setups and configures the server.

NAME="Amazon Linux AMI"
ID_LIKE="rhel fedora"
PRETTY_NAME="Amazon Linux AMI 2016.09"
Amazon Linux AMI release 2016.09

$ php -v
PHP 5.3.29 (cli) (built: May 12 2015 22:42:19)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2014 Zend Technologies
[ec2-user@ip-10-145-110-174 ~]$ sudo yum install php
Loaded plugins: priorities, update-motd, upgrade-helper
amzn-main | 2.1 kB 00:00:00
amzn-updates | 2.5 kB 00:00:00
1060 packages excluded due to repository priority protections
Resolving Dependencies
--> Running transaction check
---> Package php.x86_64 0:5.3.29-1.8.amzn1 will be installed
--> Processing Dependency: php-cli(x86-64) = 5.3.29-1.8.amzn1 for package: php-5.3.29-1.8.amzn1.x86_64
--> Processing Dependency: php-common(x86-64) = 5.3.29-1.8.amzn1 for package: php-5.3.29-1.8.amzn1.x86_64
--> Processing Dependency: httpd-mmn = 20051115 for package: php-5.3.29-1.8.amzn1.x86_64
--> Running transaction check
---> Package httpd.x86_64 0:2.2.34-1.16.amzn1 will be installed
--> Processing Dependency: httpd-tools = 2.2.34-1.16.amzn1 for package: httpd-2.2.34-1.16.amzn1.x86_64
---> Package php-cli.x86_64 0:5.3.29-1.8.amzn1 will be installed
---> Package php-common.x86_64 0:5.3.29-1.8.amzn1 will be installed
--> Running transaction check
---> Package httpd-tools.x86_64 0:2.2.34-1.16.amzn1 will be installed
--> Processing Conflict: php55-5.5.38-2.119.amzn1.x86_64 conflicts php < 5.5.38-2.119.amzn1
--> Processing Conflict: httpd24-tools-2.4.37-1.83.amzn1.x86_64 conflicts httpd-tools < 2.4.37
--> Processing Conflict: php55-cli-5.5.38-2.119.amzn1.x86_64 conflicts php-cli < 5.5.38-2.119.amzn1
--> Processing Conflict: httpd24-2.4.37-1.83.amzn1.x86_64 conflicts httpd < 2.4.37
--> Processing Conflict: php55-common-5.5.38-2.119.amzn1.x86_64 conflicts php-common < 5.5.38-2.119.amzn1
--> Finished Dependency Resolution
Error: php55-common conflicts with php-common-5.3.29-1.8.amzn1.x86_64
Error: php55-cli conflicts with php-cli-5.3.29-1.8.amzn1.x86_64
Error: httpd24-tools conflicts with httpd-tools-2.2.34-1.16.amzn1.x86_64
Error: httpd24 conflicts with httpd-2.2.34-1.16.amzn1.x86_64
Error: php55 conflicts with php-5.3.29-1.8.amzn1.x86_64
You could try using --skip-broken to work around the problem
You could try running: rpm -Va --nofiles --nodigest