Upgraded my WordPress server to PHP 7

I finally got the time to update PHP on my ubuntu server to PHP 7, my goodness did I find some speed. Before I updated, I tested PHP 7 on my staging environment, you have to be sure that an upgrade does not break any functionality provided with plugins.

Running my defined Selenium test scripts, I did not see any issue showing up on the site. So I went for it.

Why upgrade to PHP 7

The main reason is that you get a significant performance improvement, by using PHP 7 not only your code will be executed faster but you will also need fewer servers to serve the same amount of users. You can read more in the article PHP 7: 10 Things You Need to Know

That was one of my motivation to improve the speed of my server, from this screenshot you can see that my PHP took most of the transaction time loading a web page on my site.

WordPress Monitoring

In the end, having a few shots of Jägermeister, I took the plunge to upgraded PHP to version 7 on my production environment, Saturday/Sunday is a good time for me to do the upgrade as it is the slowest days of visitors to my site.

Upgrading Instructions

My server environment is ubuntu 14.4, so this installation information is for that server environment.

As my package archive did not include PHP 7, I found out that Ondřej Surý maintains PHP packages for Debian, and offers a package archive for PHP 7.0 on Ubuntu. The first step that you need to take is to add Ondřej’s package archive to your system’s Apt sources:

    sudo add-apt-repository ppa:ondrej/php

You’ll see a description of the PPA, followed by a prompt to continue. Press Enter to proceed.

Note: If your system’s locale is set to anything other than UTF-8, adding the PPA may fail due to a bug handling characters in the author’s name. As a workaround, you can install language-pack-en-base to make sure that locales are generated, and override system-wide locale settings while adding the PPA:

sudo apt-get install -y language-pack-en-base
sudo LC_ALL=en_US.UTF-8 add-apt-repository ppa:ondrej/php

Once the package archive is installed, update the local package to include its contents:

sudo apt-get update

Now that we have access to packages for PHP 7.0, we can replace the existing PHP installation.

First, install the new packages. This will upgrade all of the important PHP packages, with the exception of php5-mysql, which will be removed.

sudo apt-get install php7.0-cli php7.0-common libapache2-mod-php7.0 php7.0 php7.0-mysql php7.0-fpm php7.0-curl php7.0-gd php7.0-mysql php7.0-bz2

Note: If you have made substantial modifications to any configuration files in /etc/php5/, those files are still in place, and can be referenced. Configuration files for PHP 7.0 now live in /etc/php/7.0.

Don’t forget to restart apache and MySQL

sudo service mysql restart
sudo service apache2 restart

That’s it, you are ready to experience the speed of PHP 7.


Posted

in

by

Comments

2 responses to “Upgraded my WordPress server to PHP 7”

  1. Paul Knaggs Avatar
    Paul Knaggs

    Thanks saved me a lot of work upgrading my php

  2. Ravi Singh Avatar

    You have well define about all the importance and the up gradation of php. Subscribed your blog.

Leave a Reply to Ravi Singh Cancel reply

Your email address will not be published. Required fields are marked *