I need to downgrade my PHP to 5.2.x from 5.3.x Certain software I currently use requires it. I found all these link explaining how to do it but they no longer work because they show you how to use the Karmic archives to downgrade but as those archives no longer exist on archive.ubuntu.com
10 Answers
I found this script on the ubuntu forums which worked for me
http://ubuntuforums.org/showthread.php?t=1566808
On ubuntu 10.10 you'll need to install aptitude
as it is no longer installed by default.
sudo apt-get install aptitude
Even when there is no Karmic repos available, you could use older ones from 8.04. For Hardy is 5.2.4 available. So first solution is to use those links and make Karmic -> Hardy.
But mixing repos from two different realeases may become painful. So i don't suggest to add other realease to your apt sources. I prefer to install downloaded deb
with dpkg -i php_whatever.deb
and set it on hold. Last time i used hold, apt-get
did not care about setting hold, so maybe you need to install aptitude and use it for further upgrades.
5.2 is unsupported and RIFE with security holes.
However if you must use it, you can probably port the hardy-security package forward, as it is 5.2.4. It will be supported until April of 2013.
Still, you're going to be in better shape running the distro version of PHP and fixing your PHP apps than trying to deal with old broken PHP.
Uset this script on Ubuntu forum. It worked for me flawlessly. But the 'first' link above has some invalid urls and the 'second' script above is customized for apache.
You should install PHP 5.2 from source.
First of all you have to download the sources, install the required dependencies, after that configure based on your needs and install.
The steps can be found here.
-
1Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference. Aug 31, 2012 at 10:05
For all php-related packages use the historical repositories from old-releases.ubuntu.com for the karmic Ubuntu release to downgrade to php 5.2
I created a script solution here: http://ubuntuforums.org/showpost.php?p=9201854&postcount=6
it adds the histroical sources to a file /etc/apt/preferences.d/php5_2 that locks all php-related packages to karmic.
your system will stil stay on the actual release (11.10) onnly php will be taken from the old release
You can install both php versions parallel e.g. PHP 5.5x and 5.3x or even three PHP versions parallel e.g. PHP 5.5x , 5.4x and 5.3x using fastcgi.
1. Install Libs, fastCGI, git
sudo apt-get update
sudo apt-get install build-essential
sudo apt-get install libxml2 libxml2-dev libssl-dev
sudo apt-get install libcurl4-openssl-dev pkg-config
sudo apt-get install libcurl4-gnutls-dev libjpeg-dev libpng12-dev libmysqlclient-dev
sudo apt-get install git
cd /opt
sudo git clone https://github.com/cweiske/phpfarm
sudo apt-get install libapache2-mod-fastcgi apache2-mpm-worker apache2-suexec
sudo a2enmod actions fastcgi suexec
sudo service apache2 restart
2. Compile PHP and verify it
cd /opt/phpfarm/src
sudo ./compile.sh 5.3.29
cd /opt/phpfarm/inst/bin
./php-5.3.29 --version
3. Configure FastCGI
sudo mkdir /var/www/cgi-bin
cd /var/www/cgi-bin
sudo nano php-cgi-5.3.29
#!/bin/sh
PHPRC="/etc/php5/cgi/5.3.29/"
export PHPRC
PHP_FCGI_CHILDREN=3
export PHP_FCGI_CHILDREN
PHP_FCGI_MAX_REQUESTS=5000
export PHP_FCGI_MAX_REQUESTS
exec /opt/phpfarm/inst/bin/php-cgi-5.3.29
Make this file executable.
4. Create a new virtual host
Put this into your host:
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName fastcgidemo.dev
DocumentRoot /var/www/fastcgidemo
#php-cgi setup
#used for multiple php versions
FastCgiServer /var/www/cgi-bin/php-cgi-5.3.29
ScriptAlias /cgi-bin-php/ /var/www/cgi-bin/
<Directory "/var/www/fastcgidemo">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
AddHandler php-cgi .php
Action php-cgi /cgi-bin-php/php-cgi-5.3.29
<FilesMatch "\.php$">
SetHandler php-cgi
</FilesMatch>
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error_fastcgidemo.log
CustomLog ${APACHE_LOG_DIR}/access_fastcgidemo.log combined
</VirtualHost>
Add the domains to /etc/hosts
127.0.0.1 fastcgidemo.dev
5. Test everything
Enable site and restart apache and create a new file with phpinfo() in /var/www/fastcgidemo to test your configuration.
Go to browser and type in fastcgidemo.dev
Hope it helps!
Full Tutorial on:
http://www.jabommi.de/wiki/downgrade-php-5-5-to-5-3-ubuntu-14-with-multiple-php-versions/
-
Although your answer is 100% correct, it might also become 100% useless if that link is moved, changed, or the main site just disappears... :-( Therefore, please edit your answer, and copy the relevant steps from the link into your answer, thereby guaranteeing your answer for 100% of the lifetime of this site! ;-) You can always leave the link in at the bottom of your answer as a source for your material...– FabbyFeb 2, 2015 at 11:18
Why not just try to install PHP through apt-get.
After you have apache up and running:
apt-get install php5 libapache2-mod-php5
/etc/init.d/apache2 restart
Test PHP
sudo vi /var/www/info.php
Type:
<?php
phpinfo();
?>
Call that file in a browser:
e.g. http://192.168.0.100/info.php
If you want a specific version of php package you can create a file called /etc/apt/preferences.d/php
sudo gedit /etc/apt/preferences.d/php
Put the packages you want to install and corresponding versions, for example:
Package: libapache2-mod-php5 Pin: version 5.2.10* Pin-Priority: 991
Package: libapache2-mod-php5filter Pin: version 5.2.10* Pin-Priority: 991
Package: php-pear Pin: version 5.2.10* Pin-Priority: 991
Package: php5 Pin: version 5.2.10* Pin-Priority: 991
Package: php5-cgi Pin: version 5.2.10* Pin-Priority: 991
Package: php5-cli Pin: version 5.2.10* Pin-Priority: 991
Package: php5-common Pin: version 5.2.10* Pin-Priority: 991
Package: php5-curl Pin: version 5.2.10* Pin-Priority: 991
Package: php5-dbg Pin: version 5.2.10* Pin-Priority: 991
Package: php5-dev Pin: version 5.2.10* Pin-Priority: 991
Package: php5-gd Pin: version 5.2.10* Pin-Priority: 991
Package: php5-gmp Pin: version 5.2.10* Pin-Priority: 991
Package: php5-ldap Pin: version 5.2.10* Pin-Priority: 991
Package: php5-mhash Pin: version 5.2.10* Pin-Priority: 991
Package: php5-mysql Pin: version 5.2.10* Pin-Priority: 991
Package: php5-odbc Pin: version 5.2.10* Pin-Priority: 991
Package: php5-pgsql Pin: version 5.2.10* Pin-Priority: 991
Package: php5-pspell Pin: version 5.2.10* Pin-Priority: 991
Package: php5-recode Pin: version 5.2.10* Pin-Priority: 991
Package: php5-snmp Pin: version 5.2.10* Pin-Priority: 991
Package: php5-sqlite Pin: version 5.2.10* Pin-Priority: 991
Package: php5-sybase Pin: version 5.2.10* Pin-Priority: 991
Package: php5-tidy Pin: version 5.2.10* Pin-Priority: 991
Package: php5-xmlrpc Pin: version 5.2.10* Pin-Priority: 991
Package: php5-xsl Pin: version 5.2.10* Pin-Priority: 991
Then run:
sudo apt-get update
And try again the command for installing php:
apt-get install php5 libapache2-mod-php5
Source: Various ways of running PHP 5.2 on Ubuntu 10.04 | 2bits
I would suggest you install the following:
sudo apt-get install php5=5.2.12.dfsg.1-2
E_DEPRECATED
. So it would be something likeE_ALL & ~E_NOTICE & ~E_DEPRECATED
.