Upgrade PHP and MySQL on CentOS 6 to version 5.5 and then 5.6

Due to the recent MySQL security patches, I wanted to update my version of PHP 5.4 and MySQL 5.1 to later versions on CentOS. Here is the process.

Check your RPM versions of MySQL and PHP
rpm -qa|grep mysql

Install and enable EPEL and Remi repos
wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm && rpm -Uvh epel-release-latest-6.noarch.rpm
wget http://rpms.famillecollet.com/enterprise/remi-release-6.rpm && rpm -Uvh remi-release-6*.rpm

Set "enabled=1" in the epel repo file for [epel]
vi /etc/yum.repos.d/epel.repo
[epel]
name=Extra Packages for Enterprise Linux 6 - $basearch
#baseurl=http://download.fedoraproject.org/pub/epel/6/$basearch
mirrorlist=http://mirrors.fedoraproject.org/metalink?repo=epel-6&arch=$basearch
failovermethod=priority
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6

Set "enabled=1" in the epel remi file for [remi]
vi /etc/yum.repos.d/remi.repo
[remi]
name=Remi's RPM repository for Enterprise Linux 6 - $basearch
#baseurl=http://rpms.remirepo.net/enterprise/6/remi/$basearch/
mirrorlist=http://rpms.remirepo.net/enterprise/6/remi/mirror
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi

Try updating MySQL now.
yum update mysql*
NOTE: Here I got a dependency error/check because of php54w-pecl-memcache, so ended up having to remove it.
rpm -e php54w-pecl-memcache-3.0.8-2.w6.x86_64

So I found it better to update PHP first and MySQL updated automatically with it!

yum update php

This will update PHP to version 5.4 and MySQL to 5.5.53
Check your versions
mysql -v
php -v
They should 5.5.53 and 5.4
To update PHP to version 5.5.

Update the remi repo file - Set "enabled=1" for [remi-php55]
vi /etc/yum.repos.d/remi.repo
[remi-php55]
name=Remi's PHP 5.5 RPM repository for Enterprise Linux 6 - $basearch
#baseurl=http://rpms.remirepo.net/enterprise/6/php55/$basearch/
mirrorlist=http://rpms.remirepo.net/enterprise/6/php55/mirror
# NOTICE: common dependencies are in "remi-safe"
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi

Now run the update PHP again - this will upgrade it to version 5.5
yum update php

Check your versions again.
mysql -v 
php -v

I found I had an error with the ioncube loader - so update that too.
yum install php-ioncube-loader.x86_64
yum install php55-php-ioncube-loader.x86_64

vi /etc/php.ini
and comment out the reference to ioncube.so.

Now running php worked without any warning!

Stop and Start HTTPD and MYSQL just to make sure all is working!
/etc/init.d/httpd stop
/etc/init.d/mysqld stop
/etc/init.d/mysqld start
/etc/init.d/httpd start


UPGRADING TO PHP 5.6 and MySQL 5.6

I next wanted to install Mageneto 2 and so had to upgrade PHP and MySQL.

to upgrade PHP, edit remi.repo - then disable the 5.5 RPM and enable 5.6 RPM.

vi /etc/yum.repos.d/remi.repo

[remi-php55]
name=Remi's PHP 5.5 RPM repository for Enterprise Linux 6 - $basearch
...
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi

[remi-php56]
name=Remi's PHP 5.6 RPM repository for Enterprise Linux 6 - $basearch
...
enabled=1

yum update php

Next I had to upgrade MySQL to 5.6. Try updating it first without changing anything and restart the server to make sure it works.

yum update mysql
/etc/init.d/mysql restart

Next download the MYSQL repo RPM and install it.

wget http://repo.mysql.com/mysql-community-release-el6-5.noarch.rpm
rpm -ivh mysql-community-release-el6-5.noarch.rpm

install it using yum :
yum install mysql-server

this will upgrade MySQL to version 5.6 so restart the server.

/etc/init.d/mysql restart

If for some reason you get problems - check /var/log/mysql.log
I had to edit /etc/my.cnf and comment out "table_cache" entry from my old MySQL 5.5 install. Once I removed that, the server restarted fine.

Leave a Reply