In this tutorial, we will show you how to install PHP 7 on a Linux VPS. PHP is a server-side scripting language used for web development. Recently, the PHP development team announced that the major PHP 7 series has been released and it will become available to the web developers.
PHP 7 comes with numerous new and improved features. One of the most noticeable is the new Zend Engine version. Also, other important improvements are the enhanced performance and significantly reduced memory usage. Thus, PHP 7 can be up to twice as fast as PHP 5.6.
To install PHP 7 on an Ubuntu VPS, you need to login to your server via SSH. Once you are logged in, update all your system software to the latest version using the command below:
sudo apt-get update && sudo apt-get -y upgrade
Also, make sure that your system locale is set to UTF-8. PHP 7 PPA for Ubuntu is maintained by Ondřej Surý. We will use this PPA to install PHP 7 on Ubuntu 14.04.
Add the PPA to the APT sources list:
sudo add-apt-repository ppa:ondrej/php-7.0
If you get an error that the ‘add-apt-repository’ command cannot be found, it is most likely that your system misses the ‘software-properties-common’ package. Go ahead and install the required package.
sudo apt-get install software-properties-common
Once the installation is completed, rerun the command to add the PHP 7 PPA to your APT sources list.
Update the local package cache using the command:
sudo apt-get update
It could take a few moments and once it is completed you are ready to install the PHP 7 package.
sudo apt-get install php7.0
To ensure that the latest stable release of PHP 7 is installed on your server, you can run the command:
You should get something like this:
PHP 7.0.1-1+deb.sury.org~trusty+2 (cli) ( NTS ) Copyright (c) 1997-2015 The PHP Group Zend Engine v3.0.0, Copyright (c) 1998-2015 Zend Technologies with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2015, by Zend Technologies
To install additional PHP 7 modules, like ‘php7.0-mysql’, you can use the command below:
sudo apt-get install php7.0-mysql
To search the available PHP7 modules, execute:
sudo apt-cache search php7
If you like to test how PHP 7 works on your Ubuntu VPS, you can create a test PHP script. Navigate to your web server’s document root:
Create a test file:
Paste the following content:
<?php phpinfo(); ?>
Save the file and close it. Change the ownership:
chown www-data: info.php
Now, to access the file you can use your server’s IP address. Open your favorite web browser and navigate to:
The IP address 184.108.40.206 is used for testing purposes so make sure that you are using your server’s IP address. You should see a page with the current PHP information such as version, compilation options, extensions etc.
Of course you don’t have to do any of this if you use one of our Linux VPS hosting services, in which case you can simply ask our expert Linux admins to install PHP 7 for you. They are available 24×7 and will take care of your request immediately.
PS. If you liked this post please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.