Check this Out!Visit our social network pages for recent updates!

Installing PHP 7.0 or 7.1 on Ubuntu 17.04

PHP and related packages are the most commonly used software to develop PHP based websites and blogs online today. It mostly used with Linux, Apache2/Nginx and MySQL or MariaDB to create dynamic websites and blogs.

PHP 7 has become the default version of Ubuntu since 16.04 was released. It replaced PHP 5.x and provides better security and speed. If you’re going to be running blogs and websites based on PHP, it’s recommended to that you upgrade to PHP 7.0 or 7.1.

This brief tutorial is going to show you how to install both PHP 7.0 and PHP 7.1 on Ubuntu 17.04 if you haven’t done so. With PHP 7.0, it’s easy.

All one has to do to install PHP 7.0 is run the apt-get install php.7.0 commands since it’s the default version that comes with Ubuntu. PHP 7.1 on the other hand isn’t readily available on Ubuntu systems.

To install PHP 7.1 you must add a third-party repository to Ubuntu.

Step1: Installing PHP 7.0 on Ubuntu

Since PHP 7.0 comes as the default version starting with Ubuntu 16.04, all one has to do is run the commands below to install it.

sudo apt-get install php7.0

To install related PHP packages that are important to running dynamic PHP based applications with Apache2 Webserver support, run the commands below

sudo apt-get install php7.0 libapache2-mod-php7.0 php7.0-cli php7.0-common php7.0-mbstring php7.0-gd php7.0-intl php7.0-xml php7.0-mysql php7.0-mcrypt php7.0-zip

Alternatively, run the commands below to install PHP 7.0 with Nginx Webserver support

sudo apt-get install php7.0 php7.0-fpm php7.0-cli php7.0-common php7.0-mbstring php7.0-gd php7.0-intl php7.0-xml php7.0-mysql php7.0-mcrypt php7.0-zip

After the installation, confirm PHP version by running the commands below.

php -v

Output:

PHP 7.0.18-0ubuntu0.17.04.1 (cli) (built: Apr 26 2017 23:59:48) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
with Zend OPcache v7.0.18-0ubuntu0.17.04.1, Copyright (c) 1999-2017, by Zend Technologies

Step 2: Installing PHP 7.1 on Ubuntu

PHP 7.1 is not readily available on Ubuntu systems by default. To install it you must add a third-party PPA repository. There might be other ways to installing it, but this is the quickest and easiest way to install PHP 7.1 on Ubuntu.

To add the third-party PPA repository to Ubuntu, run the commands below.

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

After adding the repository to Ubuntu, run the commands below to search for all PHP packages related to PHP 7.1

sudo apt-get update
sudo apt-cache pkgnames | grep php7.1

Output:

php7.1-xml
php7.1-xsl
php7.1-mbstring
php7.1-readline
php7.1-zip
php7.1-mysql
php7.1-phpdbg
php7.1-interbase
php7.1-sybase
php7.1
php7.1-sqlite3
php7.1-tidy
php7.1-opcache
php7.1-pspell
php7.1-json
php7.1-xmlrpc
php7.1-curl
php7.1-ldap
php7.1-bz2
php7.1-cgi
php7.1-imap
php7.1-cli
php7.1-dba
php7.1-dev
php7.1-intl
php7.1-fpm
php7.1-recode
php7.1-odbc
php7.1-gmp
php7.1-common
php7.1-pgsql
php7.1-bcmath
php7.1-snmp
php7.1-soap
php7.1-mcrypt
php7.1-gd
php7.1-enchant
libapache2-mod-php7.1
libphp7.1-embed

Use the list to install all the PHP 7.1 packages on Ubuntu

Summary:

PHP and related packages help developers build dynamic web applications. Majority of the content management systems (CMS) available rely on PHP. This post shows you how to easily install it on Ubuntu systems.

PHP main configuration file is stored at this location on Ubuntu with Apache2 support.

/etc/php/7.0/apache2/php.ini

and at this location with Nginx support

/etc/php/7.0/fpm/php.ini

Thi is how to install PHP on Ubuntu

Enjoy!

You may also like the post below:

Installing MariaDB Stable and Development Versions on Ubuntu

Leave a Reply