How To Install PHP 7 on Ubuntu 14.04

Install PHP 7 on Ubuntu 14.04

In this tutorial, we will show you how to install PHP 7 on your Ubuntu 14.04. For those of you who didn’t know, PHP (PHP: Hypertext Preprocessor) is a server-side scripting language designed for web development but also used as a general-purpose programming language. PHP code is interpreted by a web server with a PHP processor module, which generates the resulting web page: PHP commands can be embedded directly into an HTML source document rather than calling an external file to process data. 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.

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple. I will show you through the step-by-step installation of PHP 7 in the Ubuntu 14.04 server.

Install PHP 7 on Ubuntu 14.04

Step 1. First of all, make sure that all packages are up to date.

sudo apt-get update
sudo apt-get upgrade

Step 2. Add the PPA (Personal Package Archive) repository for PHP 7 in your system.

sudo add-apt-repository ppa:ondrej/php-7.0
sudo apt-get install software-properties-common

Installing PHP 7 using the following command:

sudo apt-get update
sudo apt-get install php7.0

Now use the following command to check the installed PHP version on your system:

php -v

And it should look like:

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

Step 3. Install PHP 7 modules.

If you like to search all the available PHP 7 modules you can use to command:

sudo apt-cache search php7-*

You may want to install some other PHP extensions required by your applications. Here is the list:

php7.0-common - Common files for packages built from the PHP source
libapache2-mod-php7.0 - server-side, HTML-embedded scripting language (Apache 2 module)
php7.0-cgi - server-side, HTML-embedded scripting language (CGI binary)
php7.0-cli - command-line interpreter for the PHP scripting language
php7.0-phpdbg - server-side, HTML-embedded scripting language (PHPDBG binary)
php7.0-fpm - server-side, HTML-embedded scripting language (FPM-CGI binary)
libphp7.0-embed - HTML-embedded scripting language (Embedded SAPI library)
php7.0-dev - Files for PHP7.0 module development
php7.0-dbg - Debug symbols for PHP7.0
php7.0-curl - CURL module for PHP
php7.0-gd - GD module for PHP
php7.0-imap - IMAP module for PHP
php7.0-intl - Internationalisation module for PHP
php7.0-ldap - LDAP module for PHP
php7.0-pgsql - PostgreSQL module for PHP
php7.0-pspell - pspell module for PHP
php7.0-recode - recode module for PHP
php7.0-snmp - SNMP module for PHP
php7.0-tidy - tidy module for PHP
php7.0-json - JSON module for PHP
php-all-dev - package depending on all supported PHP development packages
php7.0-sybase - Sybase module for PHP
php7.0-modules-source - PHP 7.0 modules source package
php7.0-sqlite3 - SQLite3 module for PHP
php7.0-mysql - MySQL module for PHP

Step 4. Testing PHP 7 on Ubuntu 14.04

To test out PHP7, we need to create a PHP file a named info.php  /var/www/html/  using your favorite editor and insert the following lines of code:

nano /var/www/html/info.php
<?php
phpinfo();
?>

Test out this  page in your browser with the following hyperlink with your IP address and you should see a page with the current PHP information such as version, compilation options, extensions, etc:

http://your-ip-address/info.php

Congratulations! You have successfully installed PHP 7. Thanks for using this tutorial for installing PHP 7 on your Ubuntu 14.04 system. For additional help or useful information, we recommend you check the official PHP website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!

Save