The CentOS 7 official supported version of PHP is 5.4 which has reached the end of life. To keep secure and up to date with the latest features, you need at least version 7.0 of PHP on your CentOS 7 server.

To install PHP 7, you have to install and enable EPEL and Remi repositories to your CentOS 7 server with the commands below.

yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm

Next, you need to install yum-utils, a collection of useful programs for managing yum repositories and packages.

yum install yum-utils

Included in yum-utils is yum-config-manager, which you can use to enable Remi repository as the default repository for installing different PHP versions as shown.

yum-config-manager --enable remi-php70   [Install PHP 7.0]

If you want to install PHP 7.1 or PHP 7.2 on CentOS 7, just change the version number.

yum-config-manager --enable remi-php71   [Install PHP 7.1]
yum-config-manager --enable remi-php72   [Install PHP 7.2]

Now install PHP 7 with all commonly included modules.

yum install php php-mcrypt php-cli php-gd php-curl php-mysql php-ldap php-zip php-fileinfo

Finally, double check the installed version of PHP on your system.

php -v

It should output similar to the following:

PHP 7.0.31 (cli) (built: Jul 17 2018 15:30:29) ( NTS )

That's it, enjoy.


This article was last modified: Sept. 4, 2018, 10:11 a.m.

0 Comments

Please log in to leave a comment.

Add or change tags.

A comma-separated list of tags.

Share

Hacker News

Top