8

I had to do a Debian dist-upgrade on my server... in the process, PHP got upgraded to 5.4. We use ioncube which only supports up to 5.3 atm, and I'm having some trouble finding how to downgrade to 5.3 from 5.4. Anyone know how?

Carnivoris
  • 187
  • 1
  • 1
  • 3
  • 3
    I certainly hope this doesn't mean you're using debian unstable (sid) on a server. Because that'd be a really, really, really bad idea. –  Mar 08 '12 at 18:04
  • I had to do a dist-upgrade to meet certain requirements for PCI compliance –  Mar 08 '12 at 18:08
  • 2
    Sid is named after the evil kid in Toy Story. He breaks toys. And servers. –  Mar 08 '12 at 18:16
  • If the packages.debian.com site is up-to-date (which I would believe that it is) then you must be on Debian Unstable. A dist-upgrade would not move you to a different release. – AndrewR Mar 08 '12 at 18:17
  • @duskwuff it's called unstable but it's not really unstable. In some occasions it may be better than the stable release. Obviously on a public server is not often the best solution, because it doesn't get fast security updates by the debian security team... –  Mar 08 '12 at 18:45
  • @dAm2K The whole point of sid/unstable is that it's where new packages go for testing. While it's *usually* not broken, there are no guarantees, and upgrading at the wrong moment *might* give you a broken system if you're unlucky. See http://www.debian.org/releases/sid/ for details. –  Mar 08 '12 at 19:48
  • I got it... it was simpler than I was making it. I had a sid reference in my sources list for some reason and that's what got php 5.4. I removed that and added the wheezy sources and upgraded. That fixed it. –  Mar 08 '12 at 20:33
  • "I had to do a dist-upgrade to meet certain requirements for PCI compliance"... and using an unstable distribution is good for PCI compliance? – ceejayoz Nov 19 '12 at 15:39
  • @dAm2K: unstable does get speedy security updates these days, except for a short time (a month or so?) after a new release is promoted to stable so that isn't so much why you shouldn't use it in production. Updates go in there with relatively little testing compared to the other branches of course (as it exists in order to do some of that testing before updates are sent up the chain) which is why it isn't recommended for production use. – David Spillett Nov 21 '12 at 10:24

6 Answers6

11

Neither of the solutions above worked for me. What did work was pinning the necessary packages to the old stable such as

Add the following to /etc/apt/sources.lst

deb http://ftp.us.debian.org/debian/ squeeze main contrib non-free
deb-src http://ftp.us.debian.org/debian/ squeeze main contrib non-free

Create

/etc/apt/preferences.d/preferences

And add the packages you need downgraded such as in my case

Package: php5*
Pin: release a=oldstable
Pin-Priority: 700

Package: libapache2-mod-php5    
Pin: release a=oldstable
Pin-Priority: 700

Package: libapache2-mod-php5
Pin: release a=oldstable
Pin-Priority: 700

Package: php-pear
Pin: release a=oldstable
Pin-Priority: 700

Package: *
Pin: release a=stable
Pin-Priority: 600

Then run the commands

aptitude update
aptitude reinstall <necessary packages>
/etc/init.d/apache2 restart

If you want to know which packages you need to upgrade just run :

dpkg -l|grep php|grep 5.4|awk '{print $2}'
foobar
  • 103
  • 4
Fat Finger
  • 181
  • 2
  • 7
  • 1
    W: Failed to fetch http://ftp.us.debian.org/debian/dists/squeeze/main/source/Sources: 404 Not Found [IP: 2610:148:1f10:3::89 80] – dionyziz May 31 '16 at 22:15
  • You need to update the sources.list file with this now: `deb http://archive.debian.org/debian squeeze main contrib non-free deb-src http://archive.debian.org/debian squeeze main contrib non-free` See https://wiki.debian.org/DebianSqueeze – StevieD Apr 09 '17 at 14:21
2

You could try this, but do it at your own risk. I didn't try it myself. ;)

  • apt-get remove php5
  • Download the PHP5 package from Stable
  • dpkg --force php5_5.3.3-7+squeeze8_all.deb
  • dpkg --set-selections PHP5 hold

The last line to prevent upgrading to 5.4. When you're ready for 5.4, run dpkg --set-selections PHP5 install

IonCube for 5.4 is a little while out from what I've read.

AndrewR
  • 166
  • 1
  • I've got this `dpkg: error: unknown force/refuse option 'php5_5.3.3-7+squeeze13_all.deb'` – holms Aug 08 '12 at 15:55
  • 1
    If you're still working on this, you should know that IonCube has been upgraded to work with PHP 5.4. Just stick with PHP 5.4 and download the latest IonCube libraries. – AndrewR Aug 10 '12 at 00:32
1

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/

jb7AN
  • 11
  • 1
0

Downgrading PHP 5.4 to 5.3

First check which versions are supported for php5:

apt-cache showpkg php5

Here is the script which you could find it useful (it removes PHP 5.4 and install PHP 5.3):

sudo apt-get remove --purge `dpkg -l | grep php | grep -w 5.4 | awk '{print $2}' | xargs`
VERSION="php5_5.3.3-7+squeeze8_all" # CHANGES THIS WITH YOUR VERSION OF PACKAGE
sudo apt-get install php5=$VERSION php5-cli=$VERSION php5-common=$VERSION libapache2-mod-php5=$VERSION
sudo apt-get install php5=$VERSION php5-cli=$VERSION php5-common=$VERSION libapache2-mod-php5=$VERSION
sudo apt-get install php-pear=$VERSION php5-curl=$VERSION php5-gd=$VERSION php5-intl=$VERSION php5-mysql=$VERSION php5-pspell=$VERSION php5-recode=$VERSION php5-snmp=$VERSION php5-sqlite=$VERSION php5-tidy=$VERSION php5-xmlrpc=$VERSION php5-xsl=$VERSION

Where the available versions you can check by command: apt-cache showpkg php5

After the installation, verify it by command: php --version

Please be careful and don't install any other packages without package version specified (like php5-xcache), otherwise apt-get will replace your PHP instance with 5.4 again!

To prevent this happening, you can hold these packages.

Holding packages using dpkg

To hold packages by dpkg, you can execute the following command:

echo "php5 hold" | sudo dpkg --set-selections

To hold all PHP packages, run the following command:

dpkg --get-selections | grep ^php5 | sed s/install/hold/g | sudo dpkg --set-selections

The following command will show you holding status of your php packages:

sudo dpkg --get-selections | grep ^php

Holding packages using aptitude

You can also hold packages using aptitude e.g.:

sudo aptitude hold php5

Unhold:

sudo aptitude unhold php5

Extras

See also the same questions for Ubuntu, for some more ideas.

kenorb
  • 6,499
  • 2
  • 46
  • 54
0

I would first look at what I have installed

dpkg -l |grep php

then uninstall any php that is version 5.4 example ...

apt-get remove libapache2-mod-php5 php-db php-pear php5 php5-cli php5-common

then you need to clean up the old files (not necessary but could help)

apt-get clean

then like above edit and pin

nano /etc/apt/preferences.d/preferences

if that still does not work repeat this but this time disable the repositories that are say wheeze and leave only the sid ones. you could

apt-get install --reinstall 
Khaled
  • 36,533
  • 8
  • 72
  • 99
-1

I had to do a full upgrade to wheezy by changing my apt sources to the wheezy sources. Uninstalled php, upgraded the system with the new apt sources, installed php... everything's golden.

Carnivoris
  • 187
  • 1
  • 1
  • 3