Sunday, December 26, 2010

Linux RHEL/CentOS 5.5 PHP 5.3 upgrade made easy

Please see the RHEL 5.6 update note HERE 

Just to be honest, this PHP 5.3 upgrade/update has been made painless by the GREAT folks at IUS Community Repo! The real magic is their repository setup and rather helpful "yum-plugin-replace" yum plugin. I have not seen any problem with this update path at all. My needs may be different than yours, so YMMV. This post is adapted from a previous post that focused on another program that just needed a PHP > 5.2 installed.

You must be the root user to execute all the stated commands.


  • install the IUS and EPEL repository:
    wget http://dl.iuscommunity.org/pub/ius/stable/Redhat/5/i386/ius-release-1.0-8.ius.el5.noarch.rpm
    wget http://dl.iuscommunity.org/pub/ius/stable/Redhat/5/i386/epel-release-5-4.noarch.rpm
    rpm -Uhv ius-release-1.0-8.ius.el5.noarch.rpm epel-release-5-4.noarch.rpm





  • understand the possible issues with 3rd party repositories and how to use priorities or protectBase





  • install the IUS yum plugin (if you missed it from the IUS instructions):
    yum install yum-plugin-replace





  • replace the old stock php:
    yum replace php --replace-with php53





  • get an overview of what other php53 packages are available:
    yum search php53





  • if you had the old php and web server running, restart the web server:
    service httpd restart





  • if you had a mysql database server running, restart the mysqld:
    service mysqld restart





  • same goes if you had postgresql running:
    service postgresql restart
  • 18 comments:

    1. Sweet. Should i be logged in a root for this. And what do i need the current directory to be when I rum these commands. sry for the newb q's.

      ReplyDelete
    2. Yes, you need to be the root user to run the commands. The current directory does not matter. I have added the root user note. Thank you for your comment!

      ReplyDelete
    3. hi,

      Got error on:

      yum replace php --replace-width php53

      no package matching php53

      Any ideas?
      thx

      ReplyDelete
    4. Please check the note at the top regarding the 5.6 update. There is a slight name change for the php53 to php53u package.

      ReplyDelete
    5. I'm getting the following error when running "yum replace php --replace-with php53". What should I do?

      Replacing packages takes time, please be patient...

      WARNING: Unable to resolve all providers: ['config(php-common)', 'dbase.so()(64bit)', 'php-dbase', 'php-pcntl', 'php-readline', 'config(php)', 'config(php-devel)', 'config(php-fpm)', 'config(php-pdo)', 'config(php-mysql)', 'config(php-mbstring)', 'config(php-soap)', 'config(php-ncurses)', 'ncurses.so()(64bit)', 'php-ncurses', 'config(php-gd)', 'config(php-mcrypt)', 'config(php-mhash)', 'mhash.so()(64bit)', 'php-mhash']

      This may be normal depending on the package. Continue? [y/N] n

      ReplyDelete
    6. First, please check the note at the top regarding the 5.6 update. There is a slight name change for the php53 to php53u package.

      ReplyDelete
    7. i'm using centos 5.5 and also i get

      WARNING: Unable to resolve all providers: ['config(php-common)', 'dbase.so()(64bit)', 'php-dbase', 'php-mime_magic', 'config(php-pdo)', 'config(php-odbc)', 'config(php-mysql)', 'config(php-gd)', 'config(php-xmlrpc)', 'php-xmlrpc', 'config(php-mbstring)', 'config(php-xml)', 'config(php-snmp)', 'config(php-pgsql)', 'config(php-imap)', 'php-pcntl', 'config(php)']

      would be okay to press Y ?

      thanks

      ReplyDelete
    8. Thanks very much. Painless is hard for me to achieve as a n00b when working on my server so I really appreciate your generosity and time.

      ReplyDelete
    9. Incredibly helpful, thank you -- dealing with a client still using RHEL. Couple of updates/notes for others, since the packages have moved on the IUS site. The two RPMs you need are here now:

      http://dl.iuscommunity.org/pub/ius/stable/Redhat/5/i386/ius-release-1.0-8.ius.el5.noarch.rpm

      http://dl.iuscommunity.org/pub/ius/stable/Redhat/5/i386/epel-release-5-4.noarch.rpm

      ReplyDelete
    10. Thank you very much Ken! Your corrections are appreciated and done.

      ReplyDelete
    11. Hi:
      I updated PHP to 5.3.3 from the Plesk admin control panel. No problem and new version showing correctly - however, I had to remove Mcrypt before the update could proceed.
      I must have Mcrypt but came up with the php-common conflict when trying to install Mcrypt.
      It seems the PHP53u replacement is the solution but is there a way of doing it without removing all the PSA packages as mentioned in the last post?

      ReplyDelete
    12. I get an error

      Command line error: no such option: --replace-with

      ReplyDelete
    13. The "--replace-with" option is part of the "yum install yum-plugin-replace" step. That package is from the IUS repository. Please make sure you have executed that line and/or that "rpm -q yum-plugin-replace" produces a package result.

      ReplyDelete
    14. Hi, Running yum replace, when it gets to checking dependencies, it gives this error:

      Running rpm_check_debug
      ERROR with rpm_check_debug vs depsolve:
      php is needed by (installed) zend-optimizer-3.3.3-3.i386

      Can you please help?
      Thanks

      ReplyDelete
    15. You may need to temporarily remove zend-optimizer for the php upgrade. You should be able re-install after.

      ReplyDelete
    16. Hi, I've run the command yum replace php --replace-with php53u

      I get the following warning

      WARNING: Unable to resolve all providers: ['config(php-common)', 'dbase.so()(64bit)', 'php-dbase', 'php-mime_magic', 'php-pcntl', 'config(php)', 'config(php-pdo)', 'config(php-mysql)', 'config(php-gd)']

      If I say Y will this cause problems with stuff thats already working?

      I am running centos5.5 64bit

      ReplyDelete