2

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

  • 2
    PHP 5.2 has been end-of-lifed, you should probably move on to 5.3. If you are somehow dealing with code that works in 5.2 but does not in 5.3, you should focus your efforts on fixing that code instead. – Charles Jan 6 '11 at 8:02
  • 1
    Charles -- not an ideal world, mate. I'm trying to do this because PEAR is hosed on 5.3. I'm sick of the deprecation warnings. – Mike Crowe Feb 4 '11 at 17:16
  • 1
    In that case I'd suggest changing the error_reporting setting in php.ini to exclude E_DEPRECATED. So it would be something like E_ALL & ~E_NOTICE & ~E_DEPRECATED. – igorw Feb 12 '11 at 9:28
  • What's wrong with 5.3? – psusi Jan 19 '12 at 15:43
  • 1
    what's your point, you need php 5.2 instead of php 5.3 which is proposed by default? – user86682 Aug 31 '12 at 9:00

10 Answers 10

2

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
1

try one of these links: first second

1

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.

1

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.

0

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.

0

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.

  • 1
    Whilst 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. – Eliah Kagan Aug 31 '12 at 10:05
0

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

0

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... – Fabby Feb 2 '15 at 11:18
0

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

Source

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

  • Nop! that will install the latest one -> 5.3.10 not 5.2 – Achu Aug 31 '12 at 11:05
  • I've updated my answer – LnxSlck Aug 31 '12 at 12:37
-2

I would suggest you install the following:

sudo apt-get install php5=5.2.12.dfsg.1-2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.