Learn How To Upgrade To PHP 7 On The WordPress App

October 18, 2019

Table of Contents

Recently, in December, 2015, PHP version 7 was released as a major upgrade for its predecessor, PHP 5. Compared to the last major version in PHP 5, PHP 5.6, PHP 7 introduced multiple significant improvements: up to 2x performance, significantly reduced memory usage, consistent 64-bit support, and numerous bug fixes, along with some new features like abstract syntax tree, return type declaration, and scalar type declaration.

If you want to make the most of PHP 7 right now, on RPM-based distributions, you can use the IUS Yum repository to perform the upgrade.

Note: Despite of the significant improvements PHP 7 introduces, you need to run thorough compatibility tests in the developing and staging environments before you deploy PHP 7 in your production environment in case of any unexpected issues with code-incompatibility.

In this article, as a demo, we will introduce to you how to upgrade the pre-installed PHP 5 to PHP 7 on An ITWeb.Services WordPress app server instance which is based on CentOS 6, PHP 5, Nginx, and MySQL.


Before proceeding, you need to:

  • Deploy a new server instance with the IT Web Services WordPress app.
  • https://www.itweb.services/tutorials/linux-guides/how-to-use-sudo-on-debian-centos-and-freebsd”>IT Web Services article.

Step 1: Update the system

If your project does not have special requirements on the version of each program in the system, it is always a good practice to update every program in the system to the latest stable version.

sudo yum update

Step 2: Uninstall the pre-installed PHP 5 packages

List all of the installed PHP 5 packages for review:

yum list installed php* 

Remove all of the installed PHP 5 packages:

sudo yum remove php55u* 

Step 3: Install PHP 7 packages using the IUS Yum repository

Thanks to the built-in IUS Yum repository on this IT Web Services WordPress server instance, you can already use it to install the PHP 7 packages.

Here, you can install corresponding PHP 7 packages in accordance with the former PHP 5 packages:

sudo yum install php70u-cli.x86_64 php70u-common.x86_64 php70u-fpm.x86_64 php70u-gd.x86_64 php70u-mbstring.x86_64 php70u-mcrypt.x86_64 php70u-mysqlnd.x86_64 php70u-opcache.x86_64 php70u-pdo.x86_64 php70u-pear.noarch php70u-process.x86_64 php70u-xml.x86_64 php70u-xmlrpc.x86_64

Although the upgrade is not finished yet, you can have a look at the current version of PHP with the command below:

php -v

Step 4: Configure PHP-FPM

Because the upgrade operation modified the configuration of PHP-FPM, you need to reconfigure PHP-FPM, making it start on system boot:

sudo chkconfig php-fpm on

Next, we need to set php-fpm to execute as the user nginx in order to ensure WordPress media uploads continue to function as follows:

Open /etc/php-fpm.d/www.conf using your favorite text editor and locate the following 2 lines (usually lines 23 and 24):

user = php-fpm
group = php-fpm

Change php-fpm to nginx as follow, then save and Close the file.

user = nginx
group = nginx

Lastly, you need to restart the PHP-FPM service and the Nginx service to put your change into effect:

sudo service php-fpm restart
sudo service nginx restart

That’s it. You can use PHP 7 to serve your WordPress site now.

Need help?

Do you need help setting up this on your own service?
Please contact us and we’ll provide you the best possible quote!