PHP 7.1 has proved to be the latest stable version for development at the time of this post. If you want to install PHP 7.1+ on Ubuntu Linux, this is how to do it.
First thing we need to do is to add PHP PPA repository, that can be done via following commands:
$ sudo apt-get install software-properties-common
$ sudo add-apt-repository ppa:ondrej/php
$ sudo apt-get update
After last command issued, you can list all packages related to PHP 7.1 using this command:
$ sudo apt-cache search php7.1
php-amqp - AMQP extension for PHP
php-apcu - APC User Cache for PHP
php-geoip - GeoIP module for PHP
php-igbinary - igbinary PHP serializer
php-imagick - Provides a wrapper to the ImageMagick library
php-mongodb - MongoDB driver for PHP
php-msgpack - PHP extension for interfacing with MessagePack
php-oauth - OAuth 1.0 consumer and provider extension
php-redis - PHP extension for interfacing with Redis
php-rrd - PHP bindings to rrd tool system
php-smbclient - PHP wrapper for libsmbclient
php-solr - PHP extension for communicating with Apache Solr server
php-ssh2 - Bindings for the libssh2 library
php-uuid - PHP UUID extension
php-yac - YAC (Yet Another Cache) for PHP
php-zmq - ZeroMQ messaging bindings for PHP
php-radius - radius client library for PHP
php-http - PECL HTTP module for PHP Extended HTTP Support
php-uploadprogress - file upload progress tracking extension for PHP
php-yaml - YAML-1.1 parser and emitter for PHP
php-all-dev - package depending on all supported PHP development packages
php-xdebug - Xdebug Module for PHP
php-memcached - memcached extension module for PHP, uses libmemcached
php-apcu-bc - APCu Backwards Compatibility Module
php-memcache - memcache extension module for PHP
php-gmagick - Provides a wrapper to the GraphicsMagick library
php-tideways - Tideways PHP Profiler Extension
php-mailparse - Email message manipulation for PHP
php-gnupg - PHP wrapper around the gpgme library
php-propro - propro module for PHP
php-raphf - raphf module for PHP
php-stomp - Streaming Text Oriented Messaging Protocol (STOMP) client module for PHP
php-gearman - PHP wrapper to libgearman
libapache2-mod-php7.1 - server-side, HTML-embedded scripting language (Apache 2 module)
libphp7.1-embed - HTML-embedded scripting language (Embedded SAPI library)
php7.1-cgi - server-side, HTML-embedded scripting language (CGI binary)
php7.1-cli - command-line interpreter for the PHP scripting language
php7.1-dev - Files for PHP7.1 module development
php7.1-fpm - server-side, HTML-embedded scripting language (FPM-CGI binary)
php7.1-phpdbg - server-side, HTML-embedded scripting language (PHPDBG binary)
php7.1-bcmath - Bcmath module for PHP
php7.1-bz2 - bzip2 module for PHP
php7.1-common - documentation, examples and common module for PHP
php7.1-curl - CURL module for PHP
php7.1-dba - DBA module for PHP
php7.1-enchant - Enchant module for PHP
php7.1-gd - GD module for PHP
php7.1-gmp - GMP module for PHP
php7.1-imap - IMAP module for PHP
php7.1-interbase - Interbase module for PHP
php7.1-intl - Internationalisation module for PHP
php7.1-json - JSON module for PHP
php7.1-ldap - LDAP module for PHP
php7.1-mbstring - MBSTRING module for PHP
php7.1-mcrypt - libmcrypt module for PHP
php7.1-mysql - MySQL module for PHP
php7.1-odbc - ODBC module for PHP
php7.1-pgsql - PostgreSQL module for PHP
php7.1-pspell - pspell module for PHP
php7.1-readline - readline module for PHP
php7.1-recode - recode module for PHP
php7.1-snmp - SNMP module for PHP
php7.1-soap - SOAP module for PHP
php7.1-sqlite3 - SQLite3 module for PHP
php7.1-sybase - Sybase module for PHP
php7.1-tidy - tidy module for PHP
php7.1-xml - DOM, SimpleXML, WDDX, XML, and XSL module for PHP
php7.1-xmlrpc - XMLRPC-EPI module for PHP
php7.1-zip - Zip module for PHP
php7.1-opcache - Zend OpCache module for PHP
php7.1 - server-side, HTML-embedded scripting language (metapackage)
php7.1-xsl - XSL module for PHP (dummy)
php-phalcon - full-stack PHP framework delivered as a C-extension
php-ds - PHP extension providing efficient data structures for PHP 7
php-sass - PHP bindings to libsass - fast, native Sass parsing in PHP
php-lua - PHP Embedded lua interpreter
php-sodium - PHP wrapper for the Sodium cryptographic library
The above result is from my Ubuntu Linux.
Depending on your requirements, you can choose what packages to install; however, php7.1
package is the essential.
If you want to install PHP 7.1 for Laravel development, I recommend the following packages to be installed.
$ sudo apt-get install php7.1 php7.1-cli php7.1-fpm php7.1-bcmath php7.1-common php7.1-curl php7.1-imap php7.1-intl php7.1-json php7.1-mbstring php7.1-mcrypt php7.1-mysql php7.1-readline php7.1-sqlite3 php7.1-tidy php7.1-xml php7.1-zip
After installation, you can test if PHP 7.1 version is properly installed on machine or not via following command:
$ php --version
PHP 7.1.11-1+ubuntu16.04.1+deb.sury.org+1 (cli) (built: Oct 27 2017 13:49:56) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies
with Zend OPcache v7.1.11-1+ubuntu16.04.1+deb.sury.org+1, Copyright (c) 1999-2017, by Zend Technologies
To detect the location of what php.ini
file is loaded, try this command:
$ php -i | grep "Loaded Configuration"
Loaded Configuration File => /etc/php/7.1/cli/php.ini
For Ubuntu Linux, it is often located there by default.