Created
July 12, 2013 12:11
-
-
Save bogdanRada/5983993 to your computer and use it in GitHub Desktop.
Downgrading PHP 5.4 to 5.3 on Ubuntu 12.10 (Quantal)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
First, I got a list of PHP-related install packages: | |
$ dpkg --get-selections | grep php | |
libapache2-mod-php5 install | |
php-apc install | |
php-pear install | |
php5 install | |
php5-cli install | |
php5-common install | |
php5-curl install | |
php5-dev install | |
php5-gd install | |
php5-mcrypt install | |
php5-memcache install | |
php5-memcached install | |
php5-mysql install | |
php5-suhosin install | |
This list will be important later, so hold on to it. | |
While I’m looking at modules, I may as well find out what PECL modules I need:$ pecl list | |
Installed packages, channel pecl.php.net: | |
========================================= | |
Package Version State | |
oauth 1.2.3 stable | |
pecl_http 1.7.4 stable | |
Ok, hold on to that list too. | |
Finally, I removed the old versions of PHP. Beware: this will shut down your apache instances! | |
$ sudo apt-get remove php5 php5-cli php5-common php5-dev php-apc php-pear | |
Reading package lists... Done | |
Building dependency tree | |
Reading state information... Done | |
The following packages will be REMOVED: | |
libapache2-mod-php5 php-apc php-pear php5 php5-cli php5-common php5-curl php5-dev php5-gd php5-mcrypt php5-memcache php5-memcached php5-mysql php5-suhosin | |
The following held packages will be changed: | |
libapache2-mod-php5 php-apc php-pear php5 php5-cli php5-common php5-curl php5-dev php5-gd php5-mcrypt php5-memcache php5-memcached php5-mysql php5-suhosin | |
Start the uninstall and hold your breath! Ok, not really. It will all be alright in the end but you will have a bit of downtime since the next steps require some time. | |
Once the process completes, select which available version of PHP you’d like to install. | |
apt-cache showpkg php5-cli | |
... Snip ... Provides: | |
5.4.6-1ubuntu1 - phpapi-20100525 | |
5.3.5-1ubuntu7.11 - phpapi-20090626 | |
5.3.5-1ubuntu7 - phpapi-20090626 | |
You can see that I highlighted the PHP version I chose above. You may have more or less options available. Keep track of the package version (5.3.5-1ubuntu7) and the PHP build (phpapi-20090626). | |
For most packages, the standard PHP version will be available. Some packages won’t use the same version number as the default PHP package (php5-cli), so you’ll have to re-run apt-cache showpkg for each of these. Here’s an example where the version is different, but you’ll notice that the PHP build number matches up in the dependencies section. | |
$ apt-cache showpkg php5-memcache | |
... Snip ... | |
Dependencies: | |
3.0.6-6 - libc6 (2 2.15) phpapi-20100525 (0 (null)) ucf (0 (null)) memcached (0 (null)) php5-memcache:i386 (0 (null)) | |
3.0.5-1 - libc6 (2 2.7) phpapi-20090626 (0 (null)) php5-common (0 (null)) ucf (0 (null)) memcached (0 (null)) php5-memcache:i386 (0 (null)) | |
Provides: | |
3.0.6-6 - | |
3.0.5-1 - | |
You’ll notice in the case of php5-memcache above, the version 3.0.5-1 matches up with the PHP build we want (phpapi-20090626), so I installed that one. | |
Hold the package so it doesn’t get automatically upgraded on accident. Make sure to do this for each package you have installed. I’m only including a brief example for brevity. | |
echo "php5-cli hold" | dpkg --set-selections | |
Remove and install any PECL packages you need. | |
$ pecl uninstall php_http | |
$ pecl install php_http | |
Check your php version | |
$ php -v | |
PHP 5.3.5-1ubuntu7 with Suhosin-Patch (cli) (built: Apr 17 2011 13:58:11) | |
Copyright (c) 1997-2009 The PHP Group | |
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies | |
with Suhosin v0.9.32.1, Copyright (c) 2007-2010, by SektionEins GmbH | |
That’s it! Ok, admittedly there are a few more steps than there need to be. Also, the apt downgrade process is much easier in other ways, but this will ensure you get the correct version of PHP and each module that will meet your needs. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment