Prerequisites and disclaimer
My server is a Ubuntu 14.04 box that uses Apache 2.4 and PHP 5.5.9 prior to upgrade. These instructions are for Apache 2.4 users with a similar configuration, and I recommend you test in isolation before using in a production environment. Proceed at your own risk.
Step 1 – Add a new Apt source
At the time of writing, I’m using the packages maintained by a guy called Ondřej Surý (he’s worth a follow on Twitter) until there’s a Debian package for PHP 7 in the official release channels.
To do this, enter the following command into the box you’re upgrading:
sudo add-apt-repository ppa:ondrej/php
You’ll probably be prompted to enter your password at this point. Go ahead and enter it.
Step 2 – Install updates and the PHP 7.0 package
Next we’re going to update and upgrade packages on our system to ensure everything goes smoothly. You can do this in a single command with:
sudo apt-get update && sudo apt-get upgrade
Once this has finished, we’re ready to install PHP 7.0. Enter the following command into your terminal:
sudo apt-get install php7.0 php7.0-mysql libapache2-mod-php7.0 php7.0-mcrypt php7.0-curl
This will install PHP 7.0, along with a number of commonly used PHP packages including the Apache PHP 7 module. I found that everything else pretty much worked without being installed separately. That’s it pretty much. You shouldn’t need to make any configuration changes and everything should just work.
Step 3 – Test to ensure your server is using PHP 7.0
From the command line, type the following command: