openSUSE 11.2: Downgrade PHP 5.3 to 5.2

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.

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 below. 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

Software Manager for PHP 5.3

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

Software Repository for Downgrade

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

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

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

; 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.

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.

Software Repository after Downgrade

Software Repository after Downgrade


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.

Protect PHP 5.2

Protect PHP 5.2


That really really helped me a lot. Thanks wouldn't have been able to do it without this guide

I have built php 5.2 against openSUSE 11.2

Build service repo is located:

Sources are from SLES10, built against openSUSE 11.2

Dear paca, Thanks for the

Dear paca,

Thanks for the article. It looks like the PHP is built without Zlib. Any chance to see Zlib support in new builds?