How to update CentOS 5.9 with PHP 5.2 to current PHP?

First and foremost, I'm not very experienced with installing and updating Linux. I've been extremely lucky to have got this far by myself using Google and tutorial guides.

At any rate, I've got a Linode running CentOS 5.9 and PHP 5.2.10, and I want to update to a newer/latest version. It doesn't seem that the YUM repository offers this. Do the 'experts' have suggestions, or can someone point me to an updated guide? Thank you in advance.

8 Replies

You don't. RHEL (and therefore CentOS) backports security patches into THEIR latest STABLE version (which for CentOS 5.9 PHP v5.16).

CentOS v6.4 runs PHP v5.3.3 and you can get PHP v5.4 if you add the REMI repo.

Whatever you do - don't add the webtatic repo -that repo is NOTHING but trouble.

Why are you running CentOS v5.x instead of the current v6.x?

As I suspected, and wanted to make sure that research wasn't overshadowed by my lack of knowledge on the subject.

I am running CentOS 5 because that's what I began the server with back in 2010, and because I don't know how to upgrade without breaking something.

Feel free to make suggestions, link a guide, or offer your services. :)

Since Linode prorates their services, why not spin up a new CentOS 6.4 node, add the remi repo, install PHP 5.4, install/copy your apps and data from your PRODUCTION (not to be touched) node and see what happens. If it all works as expected, then just switch IP's from your old v5.9 node to your shiny new v6.4 node and cancel your old node. If it doesn't work, just cancel the new experimental node and it will be prorated to the small bit of time you played around with it.

Why do you think you need a newer version of PHP?

PHP 5.3.3 is included in the base repository for CentOS 5. You will need to remove the php* packages and install the corresponding php53* packages. I had to do this for a newer MediaWiki version that didn't support PHP 5.1, and it went smoothly, but I could afford the hour or so of downtime involved. Whether you want to do this on your running system is your choice.

@Vance:

PHP 5.3.3 is included in the base repository for CentOS 5. You will need to remove the php* packages and install the corresponding php53* packages. I had to do this for a newer MediaWiki version that didn't support PHP 5.1, and it went smoothly, but I could afford the hour or so of downtime involved. Whether you want to do this on your running system is your choice.

You've got my attention! Since I've never had to remove PHP (or any package, really) and have no idea how to do it, can you point me to a guide or tutorial? Anything you can provide would be helpful.

I couldn't find a decent pre-existing HOWTO on upgrading from php to the php53 base packages in CentOS 5, so here's an attempt. You may want to start with a yum clean all to clear any cached data. These commands need to be run as root.

First, run yum list installed 'php'* to see what packages you're currently using. You'll get something like this:

php.i386               5.1.6-39.el5_8        installed
php-cli.i386           5.1.6-39.el5_8        installed
php-common.i386        5.1.6-39.el5_8        installed
php-gd.i386            5.1.6-39.el5_8        installed
php-mysql.i386         5.1.6-39.el5_8        installed
php-pdo.i386           5.1.6-39.el5_8        installed
php-xml.i386           5.1.6-39.el5_8        installed

Then find out what PHP 5.3 packages and modules are available with yum list available 'php53'*:

php53.i386               5.3.3-13.el5_9.1         updates
php53-bcmath.i386        5.3.3-13.el5_9.1         updates
php53-cli.i386           5.3.3-13.el5_9.1         updates
php53-common.i386        5.3.3-13.el5_9.1         updates
php53-dba.i386           5.3.3-13.el5_9.1         updates
php53-devel.i386         5.3.3-13.el5_9.1         updates
php53-gd.i386            5.3.3-13.el5_9.1         updates
php53-imap.i386          5.3.3-13.el5_9.1         updates
php53-intl.i386          5.3.3-13.el5_9.1         updates
php53-ldap.i386          5.3.3-13.el5_9.1         updates
php53-mbstring.i386      5.3.3-13.el5_9.1         updates
php53-mysql.i386         5.3.3-13.el5_9.1         updates
php53-odbc64.i386        5.3.3-2.el5              base
php53-odbc.i386          5.3.3-13.el5_9.1         updates
php53-pdo.i386           5.3.3-13.el5_9.1         updates
php53-pgsql.i386         5.3.3-13.el5_9.1         updates
php53-process.i386       5.3.3-13.el5_9.1         updates
php53-pspell.i386        5.3.3-13.el5_9.1         updates
php53-snmp.i386          5.3.3-13.el5_9.1         updates
php53-soap.i386          5.3.3-13.el5_9.1         updates
php53-xml.i386           5.3.3-13.el5_9.1         updates
php53-xmlrpc.i386        5.3.3-13.el5_9.1         updates

If there is a corresponding php53 package for each php one you have installed, you're good. Otherwise, you may have to use other repositories to get the missing packages, or you may not actually need those modules at all. We'll assume that everything you need is there, as in this example. You will want to stop your web server using service httpd stop (for Apache).

Now you will remove the packages with yum remove php php-cli php-common php-gd php-mysql php-pdo php-xml, using the names of the packages from the first step. Yum may want to remove other packages that depend on these. Make sure you note all the names of these packages.

Then you can install the 5.3 packages using yum install php53 php53-cli php53-common php53-gd php53-mysql php53-pdo php53-xml. Also include the names of any other packages that were removed in the previous step. If yum complains that some dependencies can't be resolved, then one or more of those additional packages are marked as requiring PHP 5.1. You can revert back to your original setup by running something like yum install php php-cli php-common php-gd php-mysql php-pdo php-xml, including the names of any additional packages removed in the prior step.

If the php53 install succeeded, then you can restart the web server with service httpd start, although it might be a good idea to just reboot the entire server to make sure everything's working. Then you can try visiting your web applications to make sure they behave as expected. That's about it.

Thank you for the help, Vance. I decided to move forward on this today, and so here's what I'm working with:

Installed Packages
php.i386                          5.2.10-1.el5.centos                  installed
php-cli.i386                      5.2.10-1.el5.centos                  installed
php-common.i386                   5.2.10-1.el5.centos                  installed
php-devel.i386                    5.2.10-1.el5.centos                  installed
php-gd.i386                       5.2.10-1.el5.centos                  installed
php-mbstring.i386                 5.2.10-1.el5.centos                  installed
php-mcrypt.i386                   5.2.9-2.el5.centos.3                 installed
php-mysql.i386                    5.2.10-1.el5.centos                  installed
php-pdo.i386                      5.2.10-1.el5.centos                  installed
php-snmp.i386                     5.2.10-1.el5.centos                  installed

I will admit that it's unclear why some of the packages are installed, so when I install the new ones I'll do so step by step. Here are the available packages:

Available Packages
php53.i386                              5.3.3-13.el5_9.1                 updates
php53-bcmath.i386                       5.3.3-13.el5_9.1                 updates
php53-cli.i386                          5.3.3-13.el5_9.1                 updates
php53-common.i386                       5.3.3-13.el5_9.1                 updates
php53-dba.i386                          5.3.3-13.el5_9.1                 updates
php53-devel.i386                        5.3.3-13.el5_9.1                 updates
php53-enchant.i386                      5.3.3-1.el5                      epel   
php53-gd.i386                           5.3.3-13.el5_9.1                 updates
php53-imap.i386                         5.3.3-13.el5_9.1                 updates
php53-interbase.i386                    5.3.3-1.el5                      epel   
php53-intl.i386                         5.3.3-13.el5_9.1                 updates
php53-ldap.i386                         5.3.3-13.el5_9.1                 updates
php53-mapi.i386                         7.0.13-1.el5                     epel   
php53-mbstring.i386                     5.3.3-13.el5_9.1                 updates
php53-mcrypt.i386                       5.3.3-1.el5                      epel   
php53-mssql.i386                        5.3.3-1.el5                      epel   
php53-mysql.i386                        5.3.3-13.el5_9.1                 updates
php53-odbc.i386                         5.3.3-13.el5_9.1                 updates
php53-odbc64.i386                       5.3.3-2.el5                      base   
php53-pdo.i386                          5.3.3-13.el5_9.1                 updates
php53-pgsql.i386                        5.3.3-13.el5_9.1                 updates
php53-php-gettext.noarch                1.0.11-3.el5                     epel   
php53-process.i386                      5.3.3-13.el5_9.1                 updates
php53-pspell.i386                       5.3.3-13.el5_9.1                 updates
php53-recode.i386                       5.3.3-1.el5                      epel   
php53-simplepie.noarch                  1.3.1-5.el5                      epel   
php53-snmp.i386                         5.3.3-13.el5_9.1                 updates
php53-soap.i386                         5.3.3-13.el5_9.1                 updates
php53-tidy.i386                         5.3.3-1.el5                      epel   
php53-xml.i386                          5.3.3-13.el5_9.1                 updates
php53-xmlrpc.i386                       5.3.3-13.el5_9.1                 updates

I ran yum install php53 php53-cli php53-common php53-devel php53-gd php53-mbstring php53-mcrypt php53-mysql php53-pdo php53-snmp and everything installed without issue. Very simple process! Here's proof that it's all installed:

Installed Packages
php53.i386                           5.3.3-13.el5_9.1                  installed
php53-cli.i386                       5.3.3-13.el5_9.1                  installed
php53-common.i386                    5.3.3-13.el5_9.1                  installed
php53-devel.i386                     5.3.3-13.el5_9.1                  installed
php53-gd.i386                        5.3.3-13.el5_9.1                  installed
php53-mbstring.i386                  5.3.3-13.el5_9.1                  installed
php53-mcrypt.i386                    5.3.3-1.el5                       installed
php53-mysql.i386                     5.3.3-13.el5_9.1                  installed
php53-pdo.i386                       5.3.3-13.el5_9.1                  installed
php53-snmp.i386                      5.3.3-13.el5_9.1                  installed

However, after restarting Apache, the WordPress website was unavailable but the Joomla website could still log into the admin console. The WordPress URL gave me a generic 500 error, but the Joomla URL displayed a theme without content. This lead me to believe there was an issue with MySQL somewhere, but then I could find/see/edit all of the content items in the admin console. I eventually resolved this to xCache, and discovered that it needed to be re-installed after the PHP update.

THANK YOU for your guidance!

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct