Upgrading to PHP 5.3.x on CentOS

To upgrade to PHP 5.3. x on CentOS follow the following steps
Note: This procedure has been tested on CentOS 5.5, but it should work for all 5.x versions, if your CentOS version is earlier than version 5, before upgrading visit the official website

  1. Upgrade CentOS
  2. # yum update
  3. Restart

    # reboot
  4. Uninstall php-5.1.x
  5. # yum remove php*
  6. Install php-5.3
  7. We have selected several extensions, but you can install only the ones you need

    # yum install php53 php53-mbstring php53-gd 
    php53-mysql php53-xml php53-soap php53-pdo
  8. Installation of PEAR
  9. CentOS-5.6 does not provide php53-pear package

    • Download http://pear.php.net/go-pear.phar

      $ wget http://pear.php.net/go-pear.phar
    • Rename /usr/share/pear to /usr/share/pear.old (this step is necessary only if you had previously installed PEAR)
    • # mv -fv /usr/share/pear a /usr/share/pear.old
    • Install PEAR

      # php go-pear.phar

      Specify the following information

      1. Installation base ($prefix)        : /usr/share/pear
      2. Temporary directory for processing : /tmp/pear/install
      3. Temporary directory for downloads  : /tmp/pear/install
      4. Binaries directory                 : /usr/share/pear/bin
      5. PHP code directory ($php_dir)      : /usr/share/pear/share/pear
      6. Documentation directory            : /usr/share/pear/docs
      7. Data directory                     : /usr/share/pear/data
      8. User-modifiable configuration...   : /usr/share/pear/cfg
      9. Public Web Files directory         : /usr/share/pear/www
      10. Tests directory                   : /usr/share/pear/tests
      11. Name of configuration file        : /usr/share/pear/.pearrc
    • Create symbolic link

      # sudo ln -s /usr/share/pear/bin/pear /usr/bin/pear && 
      sudo ln -s /usr/share/pear/bin/pecl /usr/bin/pecl
    • Use pear

      $ pear help
  10. If you need the mcrypt extension you must compile it (CentOS-5.6 does not provide php53-mcrypt). This procedure serves to compile another extensions that CentOS does not provide
    • Install php53-devel and then GNU Compiler Collection (GCC)

      $ sudo yum install php53-devel gcc
    • Install the mcrypt library

      $ sudo yum install libmcrypt libmcrypt-devel
    • Download php-5.3.3

      $ wget http://www.php.net/get/php-5.3.3.tar.bz2
    • Extract and go to the dir where mcrypt is

      $ tar xjvf php-5.3.3.tar.bz2
      $ cd php-5.3.3/ext/mcrypt/
    • Configure and install

      $ phpize && ./configure && make && sudo make install 
    • Create configuration file

      $ sudo echo "extension=mcrypt.so" > /etc/php.d/mcrypt.ini
    • Restart apache

      $ sudo service httpd restart
    • Check the php configuration file

      $ php -i
      mcrypt support => enabled

Leave a Comment

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.