MiksMeister MiksMeister - 11 months ago 997
Linux Question

Install php 5.3 or 5.4 on Ubuntu 16.04 Xenial and apache

I want to Install php 5.3 or 5.4 on Ubuntu 16.04 Xenial and Apache.

A tutorial points me to use PPA but they are not helping me in what I need.

I know that PHP 5.3 and 4 are obsolete but I need this for a project and is this possible? If yes then please teach me how in a step by step procedure with Apache2.

Answer Source

Before installing PHP 5.4 you need to read this notice:

Security support for PHP 5.4 has ended. You are using this repository knowing that there might be and probably are unfixed security vulnerabilities. Please upgrade to PHP 5.6 or PHP 7.0 as found in the main repository: ppa:ondrej/php

After understanding the risks , to install PHP 5.4 ,add the PPA to your sources.list:

sudo add-apt-repository ppa:ondrej/php5-oldstable
sudo apt-get update

Install it:

sudo apt-get install -y php5

To be safe , the 5.6 version can be installed as follows:

sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install php7.0 php5.6 php5.6-mysql php-gettext php5.6-mbstring php-xdebug libapache2-mod-php5.6 libapache2-mod-php7.0
sudo a2dismod php7.0 ; sudo a2enmod php5.6 ; sudo service apache2 restart