Correct way to upgrade PHP?

15 posts / 0 new
Last post
#1 Sat, 04/21/2012 - 18:47
Brook

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.

Sat, 04/21/2012 - 23:14
andreychek

Howdy,

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:

http://www.virtualmin.com/documentation/system/bleed/

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).

-Eric

Sun, 04/22/2012 - 16:00
Brook

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 -then yum install php53

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

Cheers.

Sun, 04/22/2012 - 21:09
andreychek

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

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-"

Sun, 04/22/2012 - 21:40
Brook

I'll go with the 5.2.x then :) 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:

php-devel-5.1.6-32.el5
php-imap-5.1.6-32.el5
php-pear-1.4.9-8.el5
php-common-5.1.6-32.el5
php-5.1.6-32.el5
php-snmp-5.1.6-32.el5
php-pgsql-5.1.6-32.el5
php-gd-5.1.6-32.el5
php-pdo-5.1.6-32.el5
php-mysql-5.1.6-32.el5
php-mbstring-5.1.6-32.el5
php-odbc-5.1.6-32.el5
php-cli-5.1.6-32.el5
php-xmlrpc-5.1.6-32.el5

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!

Sun, 04/22/2012 - 22:49
andreychek

Howdy,

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.

-Eric

Mon, 04/23/2012 - 00:07
Sesso

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

Mon, 04/23/2012 - 21:33
Brook

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

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
'includepkgs=php*\n'

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 http://software.virtualmin.com/bleed/centos/5/i386/virtualmin-bleed-rele...

rpm -ivh http://software.virtualmin.com/bleed/centos/5/x86_64/virtualmin-bleed-re...

But still the same.

Any ideas what I'm doing wrong?

Mon, 04/23/2012 - 22:18
andreychek

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

-Eric

Tue, 04/24/2012 - 08:27
Brook

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

includepkgs=php*

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

Tue, 04/24/2012 - 08:34
ronald
ronald's picture

mine contains

[virtualmin-bleed]
name=Red Hat Enterprise $releasever - $basearch - Virtualmin Bleeding Edge
baseurl=http://software.virtualmin.com/bleed/rhel/$releasever/$basearch/
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-virtualmin
gpgcheck=1

but you want enabled=1

Tue, 04/24/2012 - 10:45
Brook

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

virtualmin-bleed]
name=Red Hat Enterprise $releasever - $basearch - Virtualmin Bleeding Edge
baseurl=http://software.virtualmin.com/bleed/rhel/$releasever/$basearch/
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-virtualmin
gpgcheck=1
includepkgs=php* #I added this line

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

Tue, 04/24/2012 - 10:52
Brook

Ok I did that and it worked! :D 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?

Tue, 04/24/2012 - 16:30
ronald
ronald's picture

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.

Tue, 04/24/2012 - 17:07
Brook

Thanks.... done! :)

Topic locked