New Ubuntu 16.04 install with Apache2 & Multiple PHP versions on the same machine

Don’t have much time time – so a very quick guide:

sudo apt install openssh-server
sudo apt-get install -y mc openssh-client git wget apache2 build-essential php php-json
apt install software-properties-common
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update

sudo apt-get install php5.6-fpm
a2enmod proxy_fcgi setenvif
a2enconf php7.0-fpm # if you want to make 5.6 main version: > a2enconf php5.6-fpm

# Edit /etc/apache2/apache2.conf
# AllowOverride All > change to All
<Directory /var/www/>
 Options Indexes FollowSymLinks
 AllowOverride All
 Require all granted

service apache2 restart

PS: php7 will be enabled by default, in order to enable 5.6 on the same server add content from the php5.6-fpm.conf to .htaccess (not all content from there is needed, but… what the heck).

Co-installable PHP versions: PHP 5.6, PHP 7.0 and batteries included.

You can get more information about the packages at

For PHP 5.6 use: ppa:ondrej/php5-5.6
For PHP 5.5 use: ppa:ondrej/php5
For PHP 5.4 use: ppa:ondrej/php5-oldstable

More info on a new fast cgi proxy interface in Apache:

If MbString extention doesn’t work in php5.6:

> apt install php5.6 libapache2-mod-php5.6 php5.6-curl php5.6-gd php5.6-mbstring php5.6-mcrypt php5.6-mysql php5.6-xml php5.6-xmlrpc
Posted on January 2, 2017 at 22:51 by arte · Permalink
In: English, Linux

Leave a Reply