Since I always hated my CGI set-up here I took the plunge and tried to get pyblosxom running with WSGI. This is more or less a short HOWTO that shows how I did it. I am not sure if this is the best way to do it but it works for me.


  • WSGI

    This comes bundled with the latest python releases, if yours is older the easiest solution is to use easy_install. Just download and install it if you haven't done yet and then call

easy_install wsgiref


Put, and your in the same directory. Follow the directions in the file and put the <Location> entries in your httpd.conf file. Here it is once more. Do not forget to change PythonPath so all the required files are found.

<Location /weblog>
      PythonDebug Off
      SetHandler python-program
      # set PythonPath to the folders containing the files.
      PythonPath "['/path/to/mp_wsgi_handler', '/path/to/wsgi_app']+sys.path"
      PythonHandler mp_wsgi_handler::wsgi_handler
      # This should be the same as the Location above
      PythonOption ApplicationPath /weblog
      PythonOption application wsgi_app::application

That's it you can now access your blog on your server via /weblog. But what if you do not want to use http://<servername>/weblog everytime?

I wanted to do exactly that. My first try was to change

<Location /weblog>


<Location />

This more or less worked, but since mod_python now took all requests I was not able to serve static files. I reverted the change and added some .htaccess entries instead.


RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d [OR]
RewriteCond %{REQUEST_URI} ^/$
RewriteRule ^(?!weblog)(.*)$ /weblog/$1 [QSA,L]

So what are these entries doing?

If the request is not an existing file or directory

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d [OR]

OR it is the base url

RewriteCond %{REQUEST_URI} ^/$

rewrite it to /weblog but only if it isn't already /weblog

RewriteRule ^(?!weblog)(.*)$ /weblog/$1 [QSA,L]

Difficult yes, working yes, solveable in a better way maybe but I do not know how. :)

If you have any questions or comments do not hesitate to ask me.