my adventures with apache
I spent a considerable amount of time yesterday trying to figure out tweaking the setup of Apache on my iBook. After countless hours of fscking with .htaccess and mod_rewrite (and combing the URL rewriting guide), I figured out how to get Apache to load up Blosxom without requiring “blosxom.cgi” to be in the URL. (For example, instead of this entry being at http://blog.fatoprofugus.net/blosxom.cgi/2003/Aug/16/virtual-hosting
, you can see that the location box reads http://blog.fatoprofugus.net/2003/Aug/16/virtual-hosting
.) I realize that there is a FAQ on how to hide the CGI bit on the Blosxom website, but it wasn’t enough for me for some reason that I can’t recall at present.
I think it involved me trying to get the rewrite rules to be different depending on whether the file was on my iBook or whether it was on my webhost. This proved futile, so instead, I tried to set up virtual hosts on my iBook.
Having to muck around httpd.conf
again struck fear in my soul. Luckily, setting up local virtual hosts on MacOS X has been covered on macosxhints, leading me to this nifty little script that futzes with Netinfo to get virtual hosts to work for you. (Aargh. Registries. Whatever happened to plain text files? I am having Windows flashbacks. shiver)
But to the heart of the matter—how I was able to get rid of blosxom.cgi
from the URL (or is URI? I am so confused. Remind me never to read stuff about web terminology ever again.):
-
Rename
blosxom.cgi
toindex.cgi
. DO NOT play with$url
if you intend to do development on your own computer and then just mirror the contents to your webhost. Otherwise, you can set$url
to point to your webhost. -
You need a webhost that supports
.htaccess files
. (Meaning that your webserver is configured this way. For Apache, this means mucking aroundhttpd.conf
and changing theAllowOverides
lines to the appropriate value. Being lazy, I just set them toAll
. There is surely a safer setting. On MacOSX at least, you also have to play with the user config file in/etc/httpd/users
, namedusername.conf
. Or you can just skip all this mess—I couldn’t get it to work—and installwebmin
on your computer. Yes, it may be serious overkill, but it made my life a lot easier.) Create it in your DocumentRoot, and put the following lines in:
Note that some of this stuff is from `webmin` and I don't understand all of it. You definitely need the `Rewrite` rules, and the `DirectoryIndex index.cgi` line, and at least `Options ExecCGI`. I don't know about the other stuff.
You may have to mess around with `RewriteBase`. Check out the [mod_rewrite][2] page to figure out what it does. I don't know enough to explain it correctly, so you might as well check the authoratative source.
- Now upload all your files to your host if they’re not already there, and you should be good to go.