ItecSoftware Logo

Install PHP 5.2 on Ubuntu 10.04 Lucid Lynx

Written by Peter Gilg on - like this:
install php5 ubuntu

There are many reasons why we want to install PHP 5.2 on Ubuntu 10.04 Lucid Lynx, the most prominent is that many web packages are not compatible yet with PHP 5.3. Drupal 6 being a prime example.

But there is no automated method out of the box, and there are now several scripts floating around the Internet that may work or just partially work. A major concern is the ability to update, easily switch to PHP 5.3 when the application is ready and also easily add / remove extensions.

With these considerations in mind, this is the best way to install PHP 5.2 on Ubuntu 10.04 Lucid Lynx:

We will install PHP 5.2 using apt-get and install from Ralp Janke’s repository.
First, let’s install Phyton software properties, as it makes adding the repo much easier

$ sudo apt-get install python-software-properties

Add the repository and install the GPG security verification key

$ add-apt-repository ppa:txwikinger/php5.2

Now we need to create a file called /etc/apt/preferences.d/php that locks the PHP version. This way they remain at 5.2 and don’t get upgraded to 5.3 whenever you run apt-get to upgrade

sudo vim /etc/apt/preferences.d/php

Then copy / paste the lines at the end of this article, save and quit vim.
Finally we do an update and the proper packages are pulled from the repositories:

sudo apt-get update

If you want to verify what version you’re running, simply place a file into the root of your web server with this line “<?php phpinfo(); ?>”, save it as phpinfo.php and call it in your browser.

Copy and paste these lines into /etc/apt/preferences.d/php, leaving out any extensions you don’t want or need:

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

Listed in Linux, Web Development

Tags: Lucid Lynx, php 5.2

3 responses to “Install PHP 5.2 on Ubuntu 10.04 Lucid Lynx”

  1. Hi there,

    thanks for the repository, please make sure to include all php5- modules

    see following errors when installing php5-imap php5-mcrypt

    The following packages have unmet dependencies:
    php5-imap: Depends: phpapi-20090626+lfs
    E: Broken packages

    E: Package php5-mcrypt has no installation candidate

    kind regards
    Tibor

  2. alex says:

    Any solution to the above problem?

  3. lavergini says:

    BitConstructor,
    I have the same problem, update does not help = (

Leave a Reply

Your email address will not be published. Required fields are marked *