Update Oct 23 2014: tested on ubuntu 14.10; Update Oct 29 2014: tested on Mine 17.2 (based on Ubuntu 14.04) Update Oct 29 2015: Found a load of install issued on step 1, changed recommendation from apt-get to aptitude as it reports issues far more lucidly and they all boil down to my having later versions of packages these depend on. Development files for the KDE Development Platform PIM libraries.
Months after the stable version of PHP 7.0 was released, this could be the right time for you to think of upgrading to it from the old versions.
There is always caution about upgrades especially in a production environment, but it is a good idea now to upgrade so as to enjoy speed improvements, and also features such as scalar type hinting plus many more.
You can install two versions of PHP on your system and use one for testing purposes, but remember that you only enable one PHP Apache modules in a given time.
This guide focuses on upgrading from PHP 5.X, using mod_php in connection with Apache Web server or PHP-FPM in connection with Nginx Web server.
Now let us dive into how you can upgrade to latest version of PHP and also configure your system to use it.
How to Install PHP 7 in Ubuntu 14.04 and 14.10
First, you will have to add the PPA maintained by Ondřej Surý for Debian and its derivatives such as Ubuntu by running the command below:
Next update your system as follows:
All is now set, and you can install PHP 7.0, but we shall look at upgrade for Apache and Nginx in different sections.
Upgrading to PHP 7.0 under Apache Web Server
This section is for systems running Apache, where PHP code is executed using
mod_php
module. Install the latest PHP version as running the command below:Sample Output
PHP has now been upgraded on your system, but if you are using MySQL database management system, then you will have to execute the following command to update the PHP-MySQL binding and also you will need to install some useful modules such as Curl, GD, Cli, JSON, etc.
If you want to install additional PHP7.0 modules, you can use apt-cache command to list all PHP7.0 modules and install.
Sample Output
Once PHP7.0 and its modules installed, you can restart your Apache web server and verify the PHP version as shown:
Sample Output
Dev C Ubuntu 14.10 Free
You can also verify PHP7 information by creating a
info.php
file under /var/www/html directory.Place following code and access the page via
http://server_IP-address/info.php
.Check PHP 7 Information for Apache
Upgrading to PHP 7.0 under Nginx Web Server
This section takes you through the process of upgrading to PHP7.0 and updating PHP-FPM with Nginx Web server, where PHP code is executed using PHP-FPM.
Run the command below to install the latest PHP-FPM packages:
PHP has now been upgraded, but if you are using MySQL, then you will have to execute the following command to update the PHP-MySQL binding and some additional modules as shown:
Next, you need to append the
fastcgi_pass
directive in the file /etc/nginx/sites-enabled/default or all files for your virtual sites that have to use and support PHP, since the path of the PHP-FPM socket file that PHP uses to communicate with Nginx has changed.Use your favorite editor and open the file for editing as follows:
Modify or append as follows:
Then restart Nginx and php-fpm as follows:
Lastly, you can test whether PHP is working or not by first checking the your PHP version and then testing it with the Web server.
Dev C Ubuntu 14.10 Download
You get information about your PHP packages by writing a small info.php file under /usr/share/nginx/html/ directory:
Put this code on your info.php file:
Save and exit the file.
Open your web browser, enter
http://server_IP-address/info.php
and you should be able to see the page below which shows you details about your PHP package.You can now happily use PHP 7.0 on your Ubuntu 14.04/14.10 system, and I hope you find this guide helpful.
Dev C Ubuntu 14.10 7
For any additional information concerning upgrading PHP or questions, your comments are welcome in the comment section below.