Upgrading PHP on CentOS 6.x
Learn how to upgrade PHP on CentOS 6.x by enabling external repositories and using simple commands.
Upgrading PHP on CentOS 6.x
CentOS 6.x is a stable version of this popular distribution, but it ships with outdated software packages like PHP 5.3.3 and MySQL 5.1.17. Many content management systems require newer versions of PHP and MySQL, which can be installed by enabling external software repositories.
Enabling the Extended EPEL Repository
If you have a control panel installed (like ISPManager), this step is usually optional. Otherwise, add EPEL to your repositories:
wget http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
rpm -ivh epel-release-6-8.noarch.rpm
Enabling the REMI Repository
Next, enable the REMI repository:
wget http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
rpm -Uvh remi-release-6*.rpm
Upgrading PHP and Modules
You can upgrade PHP and associated modules with:
yum -y --enablerepo=remi upgrade php-mysql php-devel php-gd php-pecl-memcache php-pspell php-snmp php-xmlrpc php-xml
This typically upgrades MySQL to version 5.5.x as well. Don’t forget to adjust the MySQL configuration by editing /etc/my.cnf and commenting out or removing the line skip-locking.
Restarting Services
After the upgrade, restart the necessary services:
service mysqld restart
service httpd restart
If you’re using ISPManager4, it’s recommended to recreate the panel’s package cache and restart it:
/usr/local/ispmgr/sbin/pkgctl cache
killall -9 ispmgr
Installing Additional Modules
The REMI repository is disabled by default. To install modules, add a flag while using yum. For example, to install PHP-GD:
yum --enablerepo=remi install php-gd
If you need to keep the REMI repository enabled, edit /etc/yum.repos.d/remi.repo. In the [remi] block, change enabled=0 to enabled=1.
Need Help?
Our support team is available 24/7 to assist you with any questions or issues.
Contact Support