3 minutes to read, 8.7K views since 2016.12.13 Читать на русском Читати українською

How to install php5.6 (5.5) on Ubuntu 16.04

prerequisite

In case you have on your vps/machine Ubuntu version 16, the default version of php you can install via apt-get install phpis the new and fancy php7.But what if you need the old and stable (or whatever you need) php 5.6 for example. Thankfully there is the guy that made thing possible. His name Ondřej Surý and you can thank to him on his site for great job he made.

installation

To install PHP 5.6 or 5.5 install Personal Package Archive (PPA) – a repository with packages from third party developers.

sudo apt-get install software-properties-common python-software-properties

add a repository, which contains PHP packages from mentioned above Ondřej Surý :

LC_ALL=C.UTF-8 sudo add-apt-repository ppa:ondrej/php

run exactly copied command, its forces to use utf-8 character set to command. In case you ommit LC_ALL=C.UTF-8 you can have problems with installing further php packages because name of the author contains umlauts.

sudo apt-get update

voila

Now we can install PHP 5.6:

sudo apt-get install php5.6

you also can install php5.5 by the following command :

sudo apt-get install php5.5

configuring

The config files are all in /etc/php/5.6 or /etc/php/5.5 respectively - inside here is where you can configure which extensions are loaded, set the ini settings, and everything else you want.

how to install modules for those versions of php?

there are lot of precompiled modules in sury's repository. so you can install most of the popular modules without problems. For example to install memcached module type the following command:

sudo apt-get install php5.6-memcached

to install it for version 5.5 of php just swap the version of php in module's name: php5.5-memcached

If you still have any questions - you're welcome to ask a question in comments