Stack Engineer

Upgrade to PHP 7.1 on CentOS

Upgrading to PHP 7.1 on CentOS 7 is a simple four step process that's outlined below. Keep in mind that PHP 7 has a lot of changes, so it's always good to test this in a development environment before bringing this to production.

Step 1 - Enable the EPEL and Webtatic Repositories

Download and install the EPEL and Webtatic repositories.

sudo rpm -Uvh https://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-9.noarch.rpm
sudo rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

Step 2 - Remove the Previous Version of PHP and Install 7

Remove the previous version of PHP, install PHP 7, and verify it installed correctly.

sudo yum remove php*
sudo yum install mod_php71w php71w-cli
php -v

Step 3 - Optional Installs

Search for other PHP 7 packages you may need and install them.

sudo yum search php71w-
sudo yum install php71w-mysql php71w-gd php71w-mcrypt php71w-mbstring php71w-pdo

Step 4 - Restart Apache

Restart the web server so it can see the changes.

sudo systemctl restart httpd