Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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?

share|improve this question

migrated from stackoverflow.com Mar 9 '12 at 2:02

This question came from our site for professional and enthusiast programmers.

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. –  duskwuff Mar 8 '12 at 18:04
    
I had to do a dist-upgrade to meet certain requirements for PCI compliance –  Carnivoris Mar 8 '12 at 18:08
2  
Sid is named after the evil kid in Toy Story. He breaks toys. And servers. –  duskwuff Mar 8 '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 8 '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... –  dAm2K Mar 8 '12 at 18:45

6 Answers 6

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}'
share|improve this answer
    
worked fine for me! thank you very much –  Stephan Jul 5 '13 at 19:04

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.

share|improve this answer
    
I've got this dpkg: error: unknown force/refuse option 'php5_5.3.3-7+squeeze13_all.deb' –  holms Aug 8 '12 at 15:55
    
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 0:32

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/

share|improve this answer

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.

share|improve this answer

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 
share|improve this answer

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.

share|improve this answer
    
which sources you could at least post them. my apt sources doesn't have any php5.3 in there =/ –  holms Aug 8 '12 at 15:58
    
Not an answer at all... –  pduersteler Jun 25 '13 at 11:06

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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