Upgrading PHP from 5.3 to 5.4 or 5.5 on CentOS 6.5 with Virtualmin

My little project upgrading PHP from 5.3 to 5.4 or 5.5 on CentOS 6.5 with Virtualmin 4 was not so simple as I wanted. A normal CentOS 6.x installation with Virtualmin installed have PHP 5.3.3 on it. It’s pretty old, so I wanted to upgrade to a newer version.

But it’s seems like CentOS 6 and Virtualmin don’t want you to upgrade, because after the upgrade, no of my PHP pages was loading, or they loaded, but they was completely blank.

But thanks to Prometeus and Mr. Salvatore I got it all fixed. So here is my guide that I’m using on any server I want to upgrade PHP on.

1. Use the Remi repository to upgrade PHP and MySQL

wget http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
wget http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
rpm -Uvh remi-release-6*.rpm epel-release-6*.rpm

yum –enablerepo=remi update -y

That will upgrade PHP from 5.3.3 to PHP 5.4.24 (15. January 2014).

If you want the newest PHP, version 5.5.x you must run the following command:

yum –enablerepo=remi,remi-php55 update -y

Your sites will now only show blank PHP pages.

2. Edit php.conf and httpd.conf

Then you have to rename php.conf with the following command:

mv /etc/httpd/conf.d/php.conf  /etc/httpd/conf.d/php.conf.no

then you have to edit the file: /etc/httpd/conf/httpd.conf and find every line with php_ in it, and remove it. I have found out that there is at least one line per domain, so be sure to remove them all. I use Filemanager in Virtualmin, and edit the file, and the use the find and replace function, an replace all php_ with # .

3. Restart httpd

Then you have to restart httpd:

service httpd restart

If there is one or more remaining lines with php_ in httpd.conf you will get an error. Then edit httpd.conf once more and be sure to remove all lines with php_ and then run service httpd restart again. Repeat to it work.

4. Then fix MySQL

The last thing you have to do, to get everything working 100% again, is to run the following command:

mysql_upgrade -u root -p

Enter your root MySQL password, and thats it. If you get a error message, you are using the wrong root MySQL password. You can change it from Webmin, Servers, MySQL Database Server and Change Administration Password.