OpenSuse Php

A couple of months ago I changed the server this website is hosted on. It only moved about 3 feet physically, but about 6 years into the future in terms of hardware. And I changed the linux distribution that it was running on from Mandrake, to Suse. Then a couple of months later, I upgraded to OpenSuse 10.

There were no dramas with any of this. Our mail archives came across fine, this blog managed to get restarted without any dramas thanks to phpMyAdmin and response to just about any connection I’d throw at it was significantly improved.

Then a couple of weeks ago, I was setting up a new site. It was just a virtual host, so nothing really needed to change. But something did. And it broke my apache web server. In trying to fix that one thing, I broke apache in about 20 other ways. Everything stopped working.

Reinstalling the webserver from scratch – new config files, moving the htdocs, updating, then downgrading everything – fixed most of my problems. But not my original one.

Today, though, I found the solution — and it works!

The problem was this: mod_rewrite wasn’t working. In fact it cause a part of apache to die every time it was called. Tragic. Ahhh, but what does mod_rewrite do, I hear you ask.

Mod_rewrite is a module loaded into apache if you want that functionality, just like loading php or ssl support. It rewrites urls so that the user doesn’t have to use an ugly looking one.

On this site, for example, this post’s real url is Mod_rewrite strips out the index.php part so it looks a bit more professional – like so:

Similarily, just visit the opensuse link mentioned previously to see mod_rewrite in action.

WordPress works just out of the box with mod_rewrite, so I was pretty thrown by it suddenly deciding not to work. I tried lots of things, but the thing that fixed it was simple.

Suse likes to have it’s own configuration settings which can overide at any time the settings you put in the real configuration files. We work as a team, and do it Suse’s way. There was a line in the config causing the drama.

When the file /etc/sysconfig/apache2 is written like this, mod_rewrite causes apache to error out:

APACHE_MODULES="access actions alias asis auth autoindex cgi dir imap include log_config mime negotiation php4 rewrite setenvif status userdir"

Written like this everything works as planned:

APACHE_MODULES="access actions alias asis auth autoindex cgi dir imap include log_config mime negotiation rewrite php4 setenvif status userdir"

Frustrating. But it works now. Be happy, Dan.

Leave a Reply