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 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!
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.
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.
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
# cd /etc/sysconfig # vi apache2
# 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
# /etc/rc.d/apache2 restart
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.
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.