вторник, септември 30, 2014

Downgrade PHP5.4 to PHP 5.3 (debian way)

Debian Wheezy comes with PHP 5.4 (or after upgrade from 6.0 to 7.0).
In PHP 5.4+  Magic Quotes was officially deprecated as of PHP 5.3.0 and removed in PHP 5.4, due to security concerns. Anyway - many old web applications depends of this feature so if you need downgrade your php installation (coz of lazy developers) here are steps:

  • First, add Debian Squeeze repositories as an additional source of packages to /etc/apt/sources.list.
deb http://ftp.debian.org/debian/ squeeze main contrib non-free
deb http://security.debian.org/ squeeze/updates main contrib non-free


  • Then, add these to pin your old PHP 5.3 packages, to /etc/apt/preferences.d/preferences. If you don’t have this file, create an empty one.

Package: 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: php-apc
Pin: release a=oldstable
Pin-Priority: 700


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

  •  This will list your PHP packages
PHP=$(dpkg -l|grep php|grep 5.4.4|awk '{print $2}')

  • Finally, reinstall:
# apt-get update
# apt-get install --reinstall $PHP

Няма коментари: