ServerAdmin and manual editing of Apache Config

Created:

I had an example of problems with ServerAdmin yesterday. I have one server (using Django) needing special settings for the Python environment. I have added that manually via two LocationMatch statements in the Apache Config for the site in question. Remember (or note) that the order of those LocationMatch statements do matter for Apache.

One of them was more specific than the other one, and the specific statement was this:


<Location "/">
   PythonHandler django.core.handlers.modpython
   SetHandler python-program
   SetEnv DJANGO\_SETTINGS\_MODULE admin.settings
   PythonPath "['/usr/local/www/example.com/django'] + sys.path"
   PythonDebug On
</Location>

The other one was:


<LocationMatch "^/(robots.txt|favicon.ico|images|css|js|media)(/|$)">
   SetHandler None
</LocationMatch>

As readers familiar with Apache and the LocationMatch statement, the order is important, and of course the order is exactly the order I here have displayed the two statements.

I wanted to have a version of this website using SSL, on a different port, so, being happy with the configuration, I cloned it using ServerAdmin.

Everything went well except that the order of the LocationMatch statements changed. I.e. ServerAdmin did not touch the old website, but the new one had the LocationMatch statements in reverse order, although I just did duplicate in ServerAdmin. Which of course made the new site not work. An hour later (I should have understood this faster) I had manually corrected the errors ServerAdmin did.

So, a recommendation: before you change any of your sites, or add a new one, copy all of the site descriptions to a separate library so you can absolutely restore to what the situation was before you started changing things manually.