To upgrade PHP and mysql on CentOS we cannot rely on the ‘yum update’ command as CentOS default repositories don’t provide versions above PHP 5.2 and MySQL 5.0.77. So we will have to rely on alternative repositories. For this purpose we will downloaded and installed the EPEL and REMI repositories. I have personally been forced to perform the upgrade on my servers due to the fact that moodle 2.1 (LMS) requires PHP 5.3.2 to operate.
What is EPEL
EPEL stand for Extra Packages for Enterprise Linux. EPEL is a Fedora Special Interest Group that creates, maintains, and manages a high quality set of additional packages for Enterprise Linux, including, but not limited to, Red Hat Enterprise Linux (RHEL), CentOS and Scientific Linux (SL).
EPEL packages are usually based on their Fedora counterparts and will never conflict with or replace packages in the base Enterprise Linux distributions. EPEL uses much of the same infrastructure as Fedora, including buildsystem, bugzilla instance, updates manager, mirror manager and more.
What is REMI
This is a repository created by Remi Collet with the aim to give support for old Fedora releases to allow them to install recent software, also it gives you the ability to have your CentOS/RHEL systems with the latest software available in the net.
Installing EPEL and REMI Repositories
or for 64 Bit server
install REMI and EPEL
rpm -Uvh remi-release-5*.rpm epel-release-5*.rpm
At this point if you attempt an ‘yum update’ for PHP or MySQL you will either be informed that there are no updates available or that no updates were made due to priority issues. So now we will set prorities for repositorys.
Now open ‘priorities.conf’ for editing (I use ‘nano’ to edit file. You can use ‘vi’ or any other command that you ae familiar with)
and make sure its content reads as follows
If this file is missing they you have to install yum priorities
yum install yum-priorities
Excluding CentOS repositories from updating PHP, MySQL
To prevent default CentOS respositories from handeling php and mysql updates we need to exclude them for those specific updates. Make the followign edits to CentOS-Base.repo
Add the following text to the end of the Base, Updates, Addons, and Extras repository entries
priority=1 exclude=*php* *mysql*
Enable (change the enable value 0 to 1) and add the following text to the end of the CentOSPlus repository entry
priority=2 exclude=*php* *mysql*
Changing Priority for EPEL and REMI repositories
open ‘epel.repo’ for edit
and add the line ‘priority=3‘ to the end of ‘[epel]’ section
open ‘remi.repo’ for edit
change enabled=0 to enabled=1 and also add the line ‘priority=3‘ to the end of ‘[remi]’ section
Update PHP and MySQL
We are ready to perform the update from the new repositories. Now if you attempt ‘yum update php php-*‘ you will get mysql dependancy issues. SO you have to update mysql first. And the magic is that along with mysql php also gets update. So all that you have to do now is:
yum update mysql
however if you see that only mysql gets updated, then you have to explicitly update all components
yum update mysql mysql-server php php-*
Restart MySql and Apache
now that you have update php and mysql, you need to restart both.
service mysqld restart # or /etc/init.d/mysqld restart
service httpd restart # or /etc/init.d/httpd restart