Sometimes, there is a need, when your application require old software to be used. Into such situation I have been dropped with some project of our client. Because of old version of Zend Optimizer (the PHP encryption software), there was a need for PHP 5.2.x with some specific extensions. The reason to select v5.2.17 is obvious - it is most secured version in the 5.2.x list.
In all official repositories of Ubuntu, there is no 5.2.17 version of PHP, and all of them propose you to upgrade everything to 5.3.x (at this time - the latest stable version).
After searching the web, I have found several solutions on how to achieve the goal:
- download PHP 5.2.17 in sources from here, and compile it from scratch, like described here. This one requires a strong knowledge of php compilation flags + PHP configuration as fast-cgi module for apache2, otherwise - a lot of time;
- find some EC2 snapshot with old Ubuntu and PHP 5.2.x preinstalled. Someone, will configure it for their needs;
- find some custom repositories with PHP v5.2.17;
The last solution was selected.
This example we will make on Amazon AWS EC2 instance. I have tried to make it with latest LTS version of Ubuntu Server (at this moment it is 12.04.1) on EC2, but there were problematic dependencies, as custom php repository compatible only with Ubuntu Lucid.
That's why, I've taken the old 10.04 LTS (Lucid) release from Amazon EC2 AMI Locator, with filter (possibly this solution will work for maverick (10.10 EOL) and natty (11.04 EOL) releases, but I was interested in LTS):
- Zone: eu-west-1 (optional for you);
- Name: lucid;
- Arch: amd64 (x64 was needed, optional for you);
- Instance Type: ebs (I like EBS, optional for you);
So, there was only one AMI solution with ID
ami-ca1a14be, and I've clicked it for auto creation.
After initial creation of instance, let's update all packages with latest versions:
sudo apt-get update
sudo apt-get -y upgrade
Step 1. Installing Apache2 (optional)
This step can be already made by you, otherwise, you should install apache before php.
To do this, type:
sudo apt-get -y install apache2
After this, you may install any mods, but no php-mod.
Step 2. Installing PHP 5.2.17
The only good solution I have found was from Victor Piskunov. I will modify his instruction a bit, and will not install mysql extension, as it is not needed for clean php setup.
So the fist sub-step is to add new repository:
sudo apt-add-repository ppa:andphe/php
And update references:
sudo aptitude update
Next one to verify, that everything is fine:
apt-cache showpkg php5-common
And you will see a bunch of packages from php 5.2.17 for lucid:
The most interesting here is
5.2.17.dfsg.1-0ubuntu0ppa3~lucid suffix. Now we can install core PHP functions itself (some of them like
pear you can remove, but they are useful for some reasons):
sudo aptitude -y install php5-common=5.2.17.dfsg.1-0ubuntu0ppa3~lucid libapache2-mod-php5=5.2.17.dfsg.1-0ubuntu0ppa3~lucid php5=5.2.17.dfsg.1-0ubuntu0ppa3~lucid php5-cli=5.2.17.dfsg.1-0ubuntu0ppa3~lucid php5-curl=5.2.17.dfsg.1-0ubuntu0ppa3~lucid php5-mcrypt=5.2.17.dfsg.1-0ubuntu0ppa3~lucid php5-gd=5.2.17.dfsg.1-0ubuntu0ppa3~lucid php5-dev=5.2.17.dfsg.1-0ubuntu0ppa3~lucid php-pear=5.2.17.dfsg.1-0ubuntu0ppa3~lucid
Now PHP 5.2.17 installed, you may try it with
Step 3. Installing extensions (optional)
For my target project, there was a need to install such extensions as memcache, and uuid. On modern versions of Ubuntu it is made with
sudo apt-get install php5-uuid. But with old system, there is other approach.
sudo apt-get install uuid-dev
sudo pecl install uuid (on path request, press ENTER)
And don't forget to
You should add "extension=uuid.so" to php.ini.
sudo pecl install memcache
And don't forget to
You should add "extension=memcache.so" to php.ini.
Same operations you can do for other extensions like pdo, pgsql, etc.
Here you can launch your own copy of Ubuntu 10.04 with PHP 5.2.17, like prepared in this article.