Lately, we’ve had clients who have upgraded from PHP4/MySQL4 to PHP5/MySQL5, only to find that they have problems with custom PHP scripts and/or Drupal modules not working any more. When that happens, there’s two choices – fix the broken code/modules, or downgrade back to PHP4. As we’re primarily running CentOS 4.X on our systems, we’ve come up with instructions on how to perform a downgrade.
Note, these instructions disable the centosplus repository as part of the downgrade. This works for us, as we’re only using centosplus for PHP5 and MySQL5. If you’re using the centosplus repository for something else, you’ll just need to exclude=php* mysql* instead of disabling the repo outright.
Downgrading From PHP5/MySQL5 on CentOS 4.X
rpm -qa | grep “php”
This will give you a list of all PHP packages on the system. Copy down this list, as you’ll need to know the package names for removal/installation.
rpm -e (packages)
Example: rpm -e php php-pear php-mbstring…
mysqldump -uroot -p —compatible=mysql40 —all-databases —add-drop-database > /databases.sql
This is our dump. You might want to use other options, but this is the requisite standard dumping procedure. —add-drop-databases is important, because we’ll be rewriting the ‘mysql’ database to restore access permissions and such.
tar -cvf /mysql5.tar.gz .
We’re making a complete backup of /var/lib/mysql – this is a safety procedure. We do have the database dump we just made, but in the event that anything is funky with that, we’ll be able to restore the database in its entirety with this.
rpm -e mysql mysql-server —nodeps
Remove any exclude=php, exclude=mysql from the [base] and [update] sections. In the [centosplus] section, set enabled=0
yum install mysql mysql-server
yum install (PHP PACKAGES)
Note, if you removed php-eaccelerator in step 2, do not list it here. CentOS 4.X distributes it only with PHP5 in the centosplus repository. If you need it for PHP4, check the end of these instructions for how to get it in RPM form.
rm -rf *
Important: Be very, very, very sure you are in /var/lib/mysql when you execute this rm -rf *
cp /etc/my.cnf.rpmsave /etc/my.cnf
mysql < /databases.sql
…For good measure.
Edit /etc/php.ini and change any settings you need to. Note, you can’t copy over /etc/php.ini.rpmsave, because PHP5 has some directory changes from PHP4. It’s almost certainly easier to just make any adjustments. Suggested adjustments:
memorylimit = 32M uploadmaxfilesize = 24M postmax_size = 24M
…And you should be good to go. Now, do you need eaccelerator? rpmforge is where it’s at:
Add ‘includepkgs=php-eaccelerator’ to the repository’s data
yum install php-eaccelerator
…And now you’re good to go with eaccelerator as well!