Install PHP 7 on CentOS 7

After I showed last week what problems you can deal with when switching from PHP 5.6 to PHP 7, I would like to show you how to switch to PHP 7 at all. Since I am now migrating to CentOS with all servers, it will be the first time that it is not a Debian example. The good thing about CentOS is that it is a fairly stable distribution – every major release is supported for 10 years. The bad thing about CentOS is that many packages are in a fairly old version, which is only provided with bug and security fixes. In my web server installations, I would rather rather operate new versions to get new features.

When you install a newer version, you have several options: either compiling PHP 7 yourself or using a third repository that contains pre-compiled packages for PHP 7. In this case I have decided for the second. With ius.io there is a repository for CentOS 7, which contains the most important packages and should be maintained for a long time due to the support of the host rackspace .

To use the IUS repository, you must first install your RPM package, which takes care of configuring the repository in the system:

In my case I install besides PHP synonymous always equal MariaDB and NGINX. The IUS repository also contains a more recent version of MariaDB. In order to install these, however, you must first remove the existing “mariadb-libs”. In the process, Postfix is ​​also uninstalled – we will simply reinstall it afterwards:

Now we can install the desired software via the software administration – packages that are installed via IUS always contain the suffix “u” to make them easier to recognize and avoid collisions with standard packages:

Basically one is now finished at this point and has its CentOS 7 equipped with PHP 7. In my case, however, there were a few more things to do, as I needed SSH support in my PHP. Since there is still no ready-made package for IUS (probably because the SSH support for PHP 7 is not yet stable ), I had to compile the extension myself.

On Github someone has made the effort to set up the sources for PHP 7 compileable – its changes will also be the basis for the future SSH module. To this Github repository I hanged myself and compiled everything myself. As soon as the stabilized packages with IUS was taken, one should of course switch to this: