openSUSE 11.2: Downgrade PHP 5.3 to 5.2

Submitted by nigel on Monday 7th December 2009

PHP 5.3 is bundled with openSUSE 11.2 which, if you are a Drupal developer, is not a good thing. As of PHP 5.3 the function ereg_replace() is deprecated - and this function is used heavily in Drupal 6 core along with many community modules. I performed the openSUSE upgrade to 11.2, and decided to see what the net result would be with respect to my Drupal development. Drupal generates a load of warnings, most of which are more annoyances than problems, but image_cache doesn't work and I have a dependency on that module so decided to downgrade from PHP 5.3 to PHP 5.2.

I thought it would be straightforward. It may well be for many, but it wasn't on my box, so I have documented the steps here in case you run into the same problems I did.

Snapshot25

Step 1 is to remove the existing PHP core and and extensions through yast. Do Kickoff->Administrator Settings->Software Manager. In the search box type 'php' and the software list will be populated to look something like mine above. At this point, make a note of all the extensions you have installed - might not be a bad idea to take a screen image like I did - or use a pen and paper!

Software Manager for PHP 5.3
Snapshot 27

You need to untick twice all the ticked boxes - this will mark them with a cross for deletion. Note: You will receive conflict warnings whilst doing this. Just ignore. Save this and the PHP system will be removed.

Step 2 is to change the Software Repositories to automate the installation of PHP 5.2. Do Kickoff->Administrator Settings->Software Repositories. One by one select the openSUSE 11.2 repositories and uncheck Enabled against each. Then select openSUSE-11.1-Update and enable. Save this with a click on ok.

Software Repository for Downgrade
Snapshot26

Step 3. Now back to Kickoff->Administrator Settings->Software Manager and again search on php in the search box. This time you should see PHP extensions with a version number commencing 5.2 in the column on the right. Recall that list of extensions you had installed with 5.3, and check the same with 5.2.

Software Manager for PHP 5.2

Ok - I bet you think you are finished now, don't you? Well, reboot first (don't just restart apache) and try it out. It may work. It didn't for me. I noticed that when I attempted to load a PHP page in my browser, my browser actually attempted to download and save the page as if I were downloading a pdf. Clearly, apache didn't know about PHP anymore.

Step 4. After some investigation it was obvious that apache wasn't loading the php module at startup. Firstly, executable bits weren't set on the php module. So fix this:

# cd /usr/lib/apache2
# chmod a+x mod_php5.so
Step 5. The module wasn't being loaded - it had been removed from the sysconfig file. So:
# cd /etc/sysconfig
# vi apache2
Add php5 to the list of modules. Mine looks like:
# apache's default installation
# APACHE_MODULES="authz_host actions alias asis auth autoindex cgi dir imap include log_config mime negotiation setenvif status userdir"
# your settings
APACHE_MODULES="actions alias auth_basic authn_file authz_host authz_groupfile authz_default authz_user authn_dbm autoindex cgi dir env expires include log_config mime negotiation setenvif ssl suexec userdir rewrite  php5 mod_vhost_alias"

If you restart apache now, you will be back in business - to a certain extent! PHP pages will now be loading, but you won't be able to connect to MySQL because of the MySQL 5.1 upgrade in openSUSE 11.2 which changed the location of the socket file.

Step 6. To combat this, you will need to edit the php.ini file.

# cd /etc/php5/apache2
# vi php.ini

and add a new default socket path in two places.

; Default socket name for local MySQL connects.  If empty, uses the built-in
; MySQL defaults.
mysql.default_socket = /var/run/mysql/mysql.sock
and
; Default socket name for local MySQL connects.  If empty, uses the built-in
; MySQL defaults.
mysqli.default_socket = /var/run/mysql/mysql.sock
Now restart apache with
# /etc/rc.d/apache2 restart
and everything should be ok BUT you will now be running PHP MySQL libraries at release 5.0.67 and MySQL server at 5.1.36. That is fine by me for my laptop but I would never do this on a production box. Only you can decide what you are comfortable with - but if you are unhappy with this version disparity, you will have to downgrade MySQL server too.
Software Repository after Downgrade
Snapshot28

Step 7. Final piece of housekeeping is to put the repositories back for openSUSE 11.2. My list is below although yours could well be different.

Optional
Snapshot 56

If you have auto-update switched on, sooner or later (probably sooner) all your work above will be wiped by the system automatically upgrading the system back to PHP 5.3. To prevent this, go back to the Software Management screen and search on PHP again. All the selected PHP components should be marked as protected. To do this, right click on each one and select "Protected - do not modify". You will then see the padlock symbol next to the package name.

blog terms
Linux PHP