Tag Archives: Virtualmin upgrade PHP 5.3 to PHP 5.4

Error Upgrading PHP 5.3 to 5.4

CentOS 6.5 ships with the default PHP 5.3.3 (although support for PHP 5.3 officially ended on 14th August 2014). Naturally, the CentOS team has backported all the security issues discovered in PHP5.3, and it is a stable and matured version. However, the PHP team at php.net recommends upgrading to PHP 5.4 to fully benefit from all the recent enhancements, bug-fixes and security patches in PHP.

This tutorial will guide you through the steps needed to upgrade PHP 5.3 to the latest PHP 5.4 without breaking any of existing websites in Virtualmin.


The first step is to install the “REMI” software repository (this software repo is maintained by French guy, Remi Collet) and it (usually) has the latest stable version of the software used by RedHat/CentOS and the EPEL repo. In fact, it requires the EPEL repo to be installed on your server before you can install the REMI repo.

Note the latest version of these software, visit:

EPEL Repo: http://fedoraproject.org/wiki/EPEL#How_can_I_use_these_extra_packages.3F

REMI Repo:  http://blog.famillecollet.com/pages/Config-en

For the purpose of this tutorial, we’ll be using the repositories for CentOS 6.5.

Step 1: Download EPEL and REMI and install the repository

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

Step 2: Update EPEL repository

yum update -y

Step 3: Enable the REMI repo and Upgrade software

yum –enablerepo=remi upgrade mysql

The command above may seemed a bit odd, why “upgrade mysql” when we want to actually upgrade PHP 5.3 to PHP 5.4? The reason is that the yum software utility will install/upgrade all dependencies to ensure that all the software pieces work together.

The default Virtualmin installation has setup “php-mysql” – and when we issue the command ‘upgrade mysql’ – the yum utility will also upgrade all the related PHP packages (e.g. php-gd, php-devel, php-mbstring, php-cli, etc) from version 5.3 to 5.4

Once the installation/upgrade process has completed, you need to run the ‘mysql_upgrade’ command to update some of the essential tables in MySQL 5.5.

mysql_upgrade -uroot

Enter the mysql root password when prompted. Once done, you can verify you have the latest version of PHP 5.4 and also MySQL 5.5


Step 4: Edit /etc/httpd/conf.d/php.conf

This is the final step before you restart Apache.  In the /etc/httpd/conf.d/ directory, you will find the following *.conf files – e.g.

  • fcgid.conf
  • php.conf
  • awstats.conf
  • webalizer.conf
  • mailman.conf
  • etc.

These are the additional directives that Apache will run each time it starts (or restarts). When we upgrade PHP 5.3 to PHP 5.4, the configuration file “php.conf” was updated to include the following lines of code:

<FilesMatch \.php$>
SetHandler application/x-httpd-php

You need to either delete  those 3 lines or comment them out. And in their place, insert:

AddHandler php5-script .php

This will prevent your PHP powered websites from breaking when you restart Apache.

Now, go ahead and issue the command to restart Apache and enjoy the latest version of PHP 5.4.34 (as of Oct 2014) on your Virtualmin server.