virtual hosts and cgi
I had this working before, mostly with the help of this script [citation on macosxhints.com][post on patrickgibson.com] Because of my iBook mishaps, all my tweaks were wiped, and I haven’t had the time to reinstate the changes.
So this is what I did (essentially doing everything that the script does manually):
- Open
/etc/httpd/httpd.conf
- Find the line
#AddHandler cgi-script .cgi
and remove the#
- Add the following lines to the end of
/etc/httpd/httpd.conf
: ` NameVirtualHost 127.0.0.1 Include /private/etc/httpd/virtualhosts ` - In
/private/etc/httpd/virtualhosts
, create a file named_localhost
- The contents of this file should be: ` <VirtualHost 127.0.0.1> DocumentRoot “/Library/WebServer/Documents” ServerName localhost <Directory “/Library/WebServer/Documents”> Options All AllowOverride None <Directory </VirtualHost> `
- Again, in
/private/etc/httpd/virtualhosts
, create a file with the same name as the virtual host name. For example, if you want a host that will be accessed withhttp://blog
, create a file namedblog
- The contents of this file should be as follows (Replace
$USERNAME
with your username and$VHOSTNAME
with your desired hostname ` <VirtualHost 127.0.0.1> DocumentRoot “/Users/$USERNAME/Sites/$VHOSTNAME” ServerName localhost <Directory “/Users/$USERNAME/Sites/$VHOSTNAME” Options Indexes FollowSymLinks ExecCGI AllowOverride All </Directory> </VirtualHost> ` - Open a root shell by typing
sudo bash
and entering your password - Run the following commands (again, replace
$VHOSTNAME
with your desired hostname): ` niutil -create . /machines/$VHOSTNAME niutil -createprop . /machines/$VHOSTNAME ip_address 127.0.0.1 niutil -createprop . /machines/$VHOSTNAME name $VHOSTNAME niutil -createprop . /machines/$VHOSTNAME serves ‘./local’ ` - Restart apache with
apachectl restart
.