How to Upgrade to PHP 7 on Ubuntu in 3 Simple Steps

This month PHP 7, the last version of PHP, has been released and brought huge performance improvements, due to the PHPNG project. You can get between 25% and 70% performance improvements on real-world apps, without having to change one single line of code (for those interested in what changed internally in PHP that allowed this, check the slides from one of the PHP core developers on SlideShare). And this doesn’t happen so often.

For detailed performance benchmarks, have a look at Rasmus Lerdorf’s presentation at PHP Australia.

As you can see from these benchmarks, PHP 7 handles more than twice as many requests per second, which in practical terms will represent a 100% improvement on performance for WordPress websites.

Being impressed by the benchmarks, I decided to update the Vauly blog to PHP7. It runs on WordPress and due to the latest changes to the WordPress Core it is fully compatible with PHP7.

Install / Upgrade to PHP 7

Thanks to Ondřej Surý, we have a package for PHP7, that will greatly simplify the upgrading process. He maintains an PPA (Personal Package Archive), that contains packages for all the supported PHP versions, including PHP7.

First we need to install python-software-properties package. This provides us with the add-apt-repository command, that we will use to add the PPA for PHP 7 in our Ubuntu system and install it.

$ apt-get install python-software-properties
$ add-apt-repository ppa:ondrej/php-7.0

If you have any custom configuration files for PHP5, now it’s time to backup them. Next, let’s remove PHP5 and install PHP7:

$ apt-get update && apt-get purge php5-fpm && apt-get --purge autoremove && apt-get install php7.0-fpm libapache2-mod-php7.0 php7.0-mysql php7.0-curl

And this kinda was it for me. Everything continued to work fine for me. Or even better, as I have made the blog at least 2 times faster than before in 3 amazingly simple steps.

Post A Comment