How to upgrade to PHP 7 on Ubuntu

How to upgrade to PHP 7 on Ubuntu

It has arrived. After a long wait Web developers can finally start migrating their code to PHP 7. But we have to upgrade from PHP 5 to PHP 7 first.  It’s not difficult at all, but you need to stay focused in a couple of places.

First of all, add the new repository for PHP 7:

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

In the next command, we’ll remove PHP 5 from your system and install PHP 7. You might want to keep a backup of your config files for reference.

$ apt-get update && apt-get purge php5-fpm && apt-get --purge auto remove && apt-get install php7.0-fpm php7.0-mysql

At this point, php5-fpm should be gone, and the php7.0-fpm service is running. It is, however, unlikely that your website is running properly – because the PHP-FPM socket file will have changed. If you’re running Nginx, you must update your fastcgi_pass directive to this:

fastcgi_pass unix:/run/php/php7.0-fpm.sock;

And restart Nginx:

 $ service nginx restart

You most likely will want to edit the PHP-FPM pool file found in


After modifying the pool file, remember to restart the PHP-FPM process:

$ service php7.0-fpm restart



Subscribe to our email list and stay up-to-date with all our awesome releases and latest updates.
MailChimp Icon