How to install php 5.2 on Cent OS 5

Linux OS Topics
Post Reply
User avatar
Saman
Lieutenant Colonel
Lieutenant Colonel
Posts: 828
Joined: Fri Jul 31, 2009 10:32 pm
Location: Mount Lavinia

How to install php 5.2 on Cent OS 5

Post by Saman » Wed Sep 08, 2010 8:44 am

I was recently stuck with some date time functions in php that are only available in php 5.2+. Unfortunately Cent OS 5 comes with php 5.1.6 and the repositories are still not updated to a later version.

After several attempts, with the help from a Linux professional (one of ROBOT.LK members) we found that it is required to add a new repo to update. I thought it would be helpful for some people who are looking for the same thing.
  1. Create a file named utterramblings.repo at /etc/yum.repos.d/
    You can use vim /etc/yum.repos.d/utterramblings.repo to edit the file.
  2. Add following code
    # FILE CONTENTS - START
    [utterramblings]
    name=Jason's Utter Ramblings Repo
    baseurl=http://www.jasonlitka.com/media/EL$rele ... $basearch/
    enabled=1
    gpgcheck=1
    gpgkey=http://www.jasonlitka.com/media/RPM-GPG-KEY-jlitka
    # FILE CONTENTS - END

    If you use vim, you can first copy the content to clipboard, press i, then paste (shift+insert), press Esc, press :wq and enter.
  3. Now type yum update
    You may have to type sudo yum update if not logged as root.

    It will run as this.

    Code: Select all

    # ...snip...
    Resolving Dependencies
    # ...snip...
    Dependencies Resolved
    
    =============================================================================
    Package                 Arch       Version          Repository        Size 
    =============================================================================
    Updating:
    apr                     i386       1.2.12-2.jason.1  utterramblings    257 k
    apr-util                i386       1.2.12-5.jason.1  utterramblings    159 k
    httpd                   i386       2.2.8-jason.3    utterramblings    2.5 M
    mod_ssl                 i386       1:2.2.8-jason.3  utterramblings    314 k
    mysql                   i386       5.0.58-jason.2   utterramblings    6.4 M
    mysql-server            i386       5.0.58-jason.2   utterramblings     10 M
    pcre                    i386       7.6-jason.1      utterramblings    562 k
    php                     i386       5.2.6-jason.1    utterramblings    3.7 M
    php-cli                 i386       5.2.6-jason.1    utterramblings    2.6 M
    php-common              i386       5.2.6-jason.1    utterramblings    481 k
    php-devel               i386       5.2.6-jason.1    utterramblings    568 k
    php-gd                  i386       5.2.6-jason.1    utterramblings    320 k
    php-ldap                i386       5.2.6-jason.1    utterramblings     56 k
    php-mbstring            i386       5.2.6-jason.1    utterramblings    1.3 M
    php-mssql               i386       5.2.6-jason.1    utterramblings     61 k
    php-mysql               i386       5.2.6-jason.1    utterramblings    258 k
    php-odbc                i386       5.2.6-jason.1    utterramblings    112 k
    php-pdo                 i386       5.2.6-jason.1    utterramblings    159 k
    php-pear                noarch     1:1.6.2-1.jason.1  utterramblings    418 k
    php-soap                i386       5.2.6-jason.1    utterramblings    342 k
    php-xml                 i386       5.2.6-jason.1    utterramblings    316 k
    php-xmlrpc              i386       5.2.6-jason.1    utterramblings    130 k
    subversion              i386       1.4.4-jason.1    utterramblings    4.3 M
    
    Transaction Summary
    =============================================================================
    Install      0 Package(s)         
    Update      23 Package(s)         
    Remove       0 Package(s)         
    
    Total download size: 35 M
    Is this ok [y/N]:
    
    Press y and enter.
  4. Type php -v | head -1 and see whether you get something as below.

    Code: Select all

    PHP 5.2.6 (cli) (built: May  5 2008 10:32:59)
    
  5. While updating, if you get a dependency problem (say with SQLite), you will have to remove them and re-install after this update.
I found that Cent OS tema has published a wiki page that does the same thing. But it updates to a older version of php. You can find that at http://wiki.centos.org/HowTos/PHP_5.1_To_5.2.
Post Reply

Return to “Linux”