Downgrade PHP 5.3 to 5.2 in centos 6
Introduction
PHP is a widely used server-side scripting language for building dynamic web applications. On older systems such as CentOS 6, different PHP versions may be required for legacy applications to function correctly. While PHP 5.3 introduced several improvements over PHP 5.2, some older web applications are not compatible with PHP 5.3 due to deprecated functions or syntax changes.
In such cases, administrators may need to downgrade PHP from version 5.3 to 5.2 to maintain application compatibility. However, this process must be handled carefully because both CentOS 6 and these PHP versions are end-of-life (EOL) and no longer receive security updates.
Prerequisites
Before proceeding with the downgrade, ensure the following requirements are met:
- You must have root privileges or sudo access to the server.
- Backup of Server and Applications
- Current PHP Version Check
IMPLEMENTATION
CentOS 6 is the latest release of centOS organization. The centos 6 normally comes with php 5.3. There are some issues with php 5.3 in the centOS 6. Some of us like to downgrade the centOS PHP version from 5.3 to 5.2. You can do the following procedures to downgrade the php version to 5.2.
1. Take the copy of the previous installed rpm to any one of the folder.
————–
[root@cronline ~]# rpm -qa|grep php >>/root/php_modules/php_module.txt
[root@cronline ~]# cat /root/php_modules/php_module.txt
php-mysql-5.3.2-6.el6_0.1.x86_64
php-pear-1.9.0-2.el6.noarch
php-cli-5.3.2-6.el6_0.1.x86_64
php-pdo-5.3.2-6.el6_0.1.x86_64
php-pecl-memcache-3.0.4-3.2.el6.2.x86_64
php-5.3.2-6.el6_0.1.x86_64
php-devel-5.3.2-6.el6_0.1.x86_64
php-imap-5.3.2-6.el6_0.1.x86_64
php-common-5.3.2-6.el6_0.1.x86_64
[root@cronline ~]#
————–
2. Remove the existing PHP 5.3 RPM in the server.
——————-
[root@cronline ~]# rpm -e –nodeps php-pecl-memcache-3.0.4-3.2.el6.2.x86_64 php-5.3.2-6.el6_0.1.x86_64 php-devel-5.3.2-6.el6_0.1.x86_64 php-imap-5.3.2-6.el6_0.1.x86_64 php-common-5.3.2-6.el6_0.1.x86_64
——————-
3. Download the corresponding PHP 5.2 version from the “http://www6.atomicorp.com/” webiste.
—————–
[root@cronline ~]# wget http://www6.atomicorp.com/channels/atomic/centos/6/x86_64/RPMS/php-mysql-5.2.17-1.el6.art.x86_64.rpm
[root@cronline ~]# wget http://www6.atomicorp.com/channels/atomic/centos/6/x86_64/RPMS/php-cli-5.2.17-1.el6.art.x86_64.rpm
[root@cronline ~]# wget http://www6.atomicorp.com/channels/atomic/centos/6/x86_64/RPMS/php-pdo-5.2.17-1.el6.art.x86_64.rpm
[root@cronline ~]# wget http://www6.atomicorp.com/channels/atomic/centos/6/x86_64/RPMS/php-5.2.17-1.el6.art.x86_64.rpm
[root@cronline ~]# wget http://www6.atomicorp.com/channels/atomic/centos/6/x86_64/RPMS/php-devel-5.2.17-1.el6.art.x86_64.rpm
[root@cronline ~]# wget http://www6.atomicorp.com/channels/atomic/centos/6/x86_64/RPMS/php-imap-5.2.17-1.el6.art.x86_64.rpm
[root@cronline ~]# wget http://www6.atomicorp.com/channels/atomic/centos/6/x86_64/RPMS/php-common-5.2.17-1.el6.art.x86_64.rpm
—————–
4. Install the downloaded PHP 5.2 RPM .
—————–
[root@cronline ~]# rpm -ivh –nodeps php-devel-5.2.17-1.el6.art.x86_64.rpm php-pdo-5.2.17-1.el6.art.x86_64.rpm php-cli-5.2.17-1.el6.art.x86_64.rpm php-mysql-5.2.17-1.el6.art.x86_64.rpm php-imap-5.2.17-1.el6.art.x86_64.rpm php-common-5.2.17-1.el6.art.x86_64.rpm
—————–
5. Finally restart the webserver.
————-
[root@cronline ~]#/etc/init.d/httpd restart
Stopping httpd: [ OK ]
Startinging httpd: [ OK ]
————-
6. The next important think is to exclude the php in yum.conf. If you are not excluding this line PHP will be upgraded if we enter yum update command in the server.
Conclusion
Downgrading PHP from 5.3 to 5.2 on CentOS 6 is primarily required for legacy application compatibility. However, this process is not recommended for production environments due to the outdated and unsupported nature of both PHP 5.2 and CentOS 6, which exposes systems to security vulnerabilities.
Instead, it is advisable to upgrade applications to support newer PHP versions whenever possible. If downgrading is unavoidable, it should be performed in a controlled environment with proper backups and testing to avoid service disruption.
