Let’s say you’re running nginx, with PHP 5 (fpm, that is) – and want to upgrade to the all-new PHP 7 (which was released on about the 4th December, 2015 – today, incidentally). Here’s how you do it – on Ubuntu, at least:

Right. To keep up with updates, let’s first add the PPA:

sudo apt-get install python-software-properties


sudo add-apt-repository ppa:ondrej/php-7.0

Next, let’s remove PHP 5 from our system, and install PHP 7:

sudo apt-get update && sudo apt-get purge php5-fpm

sudo apt-get --purge autoremove

sudo apt-get install php7.0-fpm php7.0-mysql

Now, PHP 5 should be removed and PHP 7 running. However, because the socket used with the new PHP 7 has changed, we’ll need to modify where we send the requests to with nginx.

The old statement for passing it to the socket was

fastcgi_pass unix:/var/run/php5-fpm.sock;

Find this line in your nginx config, and change it to:

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

Okay, now our config is all set. Let’s now restart nginx with

sudo service nginx restart

— and then we’re done! It should be all up and running!