For the past two hours I’ve been losing my goddamn mind trying to get CGI scripts to work on my local Mac OS X machine so that I can test some things for the third edition of Google Hacks. I usually do this sort of thing on remote shells, but because I couldn’t get this particular piece of code working on the other machines (through no fault of the code), I decided to try and run it locally.
After making the necessary changes to the httpd.conf file I tried running some CGI scripts from my web folder and kept getting 403 (Forbidden) errors. I knew my permissions were correct and so I was left to rifle through the logs to see what I could find; the httpd error log told me the following:
[Sat Apr 1 00:23:54 2006] [error] [client 127.0.0.1] Options ExecCGI is off in this directory: /Users/justin/Sites/foo.cgi
This really threw me for a loop because I explicitly added ExecCGI privileges to that directory through httpd.conf. After almost two hours of editing various files and restarting httpd, I found the following on line 1107 (the very last line!) of my httpd.conf file:
Sure enough, the justin.conf file found in /private/etc/httpd/ was overriding the changes I made to the httpd.conf file. Once I nailed that down it was just a matter of commenting out the line.1
I’m sure this is documented somewhere, but I couldn’t find it, likely because it’s been a long-ass day and I’m having trouble focusing. And on that note, good night.
Instead of commenting out this line you could just as easily modify your respective conf file in /private/etc/httpd/; this is probably the better option for multi-user systems because it keeps everyone’s configurations separate. ↩