Correct way to upgrade PHP?

What’s the best way to upgrade PHP to another version on a Virtualmin system?

I’m currently on 5.1.6, but I need to go to at least 5.2.4 for the software I need to use (I can safely go to 5.2.9 without breaking current sites on the server).

I’m using CentOS 5.8

Any help greatly appreciated.


The two recommended ways of upgrading PHP on CentOS 5 would be to either use the Virtualmin Bleed repository to upgrade to PHP 5.2.17:

Or to replace your php packages with the php53 packages that come with CentOS 5.6+, which is PHP 5.3.3.

We unfortunately don’t have a recommended way of upgrading to PHP 5.2.9, as that’s an older PHP version that contains security issues (whereas, with your PHP 5.1.6, RedHat backports security fixes into it).


Thanks Eric - that’s very helpful!

I just upgraded to 5.2.17 on my old server and it run the sites with no problem. I also tested 5.3.8 (it’s a cPanel server and 5.3.3 wasn’t available as an option) and that would be ok too so long a I upgrade the script I am using for the site - so they’re both doable, at a push.

Would you say 5.3.3 has any major benefits over 5.2.17?

Out of the two options, which would be the easiest to set-up?

Edit: Looking on the CentOS forums I see I’d need to do:

yum remove php
yum install php53

Is that correct? Is that better for a Virtualmin server? (or go with the bleeding repo?)


Going with 5.2.x is simpler – but as for which is better, that all depends on your needs :slight_smile:

Note though that you would need to remove all the php-* packages, and then replace them with the php53-* packages.

You can see them all by running:

rpm -qa | grep “^php-”

I’ll go with the 5.2.x then :slight_smile: I am moving away from PHP so hopefully won’t really need anything higher than that. Can you advise on how to upgrade please?

Here’s the results from that command:


Which do you think I can safely remove? Is ‘php-pgsql’ the postgres adapter? If so I won’t need that (but do need postrgres for my Ruby sites - I guess removing the one above won’t interfere with those?)

Is mod_php more efficient too? I’ve just swtiched all the sites over to it as the loads are higher than on my old (cpanel) server (both similar specs, 8GB ram, Core2Quad Q9300, although old server was Q9400, 2x500GB in Raid 1, old server had a single 150gb raptor ). I was expecting this server to be faster as it doesn’t have the bloat (cpanel! lol). I’ve copied over the my.cnf tweaks that my software vendor provided.

Again, thanks for all your help Eric!


The command I mentioned above is only necessary for upgrading to PHP 5.3.x.

Upgrading to PHP 5.2.x is the simpler one – you can see the instructions for that in my link to the “bleed” repo above.

Just follow the instructions in there to setup the bleed repo, and the next time you run “yum update”, it’ll be pulling down the new PHP version.


I just had this issue and did it the same way that they told you.

install VM

rm php

install php53

download the epel.repo
download the remi.repo

Now they wont be enabled which is good. You only need php53-mcrypt from the repos

yum install php53-mcrypt <------- only if you are using phpmyadmin

Thanks Sesso, on this occasion I am going with Eric’s advice of the easiest :slight_smile:

Although it didn’t work out… I’m getting this error:

Loaded plugins: fastestmirror, security
Config Error: File contains no section headers.
file: file://///etc/yum.repos.d/virtualmin-bleed.repo, line: 1

I opened ‘vi /etc/yum.repos.d/virtualmin-bleed.repo’ and added ‘includepkgs=php*’ to it (it was empty). Then tried to run ‘yum update’, but got the error above.

I’ve also tried running both of these lines:

rpm -ivh

rpm -ivh

But still the same.

Any ideas what I’m doing wrong?

Can you attach your virtualmin-bleed.repo file? That may help us diagnose what’s going on.


Hi Eric, it’s empty, apart from this line:


I removed it and then ran the rpm -ivh lines but it’s still empty when I go back to it :confused:

mine contains

name=Red Hat Enterprise $releasever - $basearch - Virtualmin Bleeding Edge

but you want enabled=1

I have a file there called: /etc/yum.repos.d/virtualmin-bleed.repo.rpmnew
Which contains the following:

name=Red Hat Enterprise $releasever - $basearch - Virtualmin Bleeding Edge
includepkgs=php* #I added this line

Should I just remove the .rpmnew from the end of it?

Ok I did that and it worked! :smiley: Thanks both!

Just a quick question - do I need to change enabled to 0 now? To prevent it automatically loading any newer versions of PHP should they get added to bleed?

yes, unless you want to update when the bleed is update … personally i don’t want to update php all the time to a newer version before it is tested.

Thanks… done! :slight_smile: