Apache Via Symbolic Links in Mac OS X
Every once in a while, you need to have a web application sit outside the "normal" places expected by Apache. Under Mac OS X (and several flavors of Linux), there are safeguards in place to prevent this.
In my apache configuration file, the DocumentRoot is /Users/markf/Sites
. However, I have a symbolic link in that directory to another location.
cd ~/Sites ls -al lrwxr-xr-x 1 markf staff 59 Jan 11 07:14 mm -> /Users/markf/Documents/workspaces/mmapp
If you try to navigate to http://localhost/mm
in your browser, you see a permission error. There are two things you must do to make this work properly.
First, you have to make sure Apache is configured to follow symbolic links.
Partial Listing: /opt/local/apache2/conf/httpd.conf
<Directory "/Users/markf/Sites"> Options Indexes FollowSymLinks AllowOverride All Order allow,deny Allow from all </Directory>
Adding "FollowSymLinks" makes it possible for Apache to "follow" the symbolic link I created to its destination.
sudo /opt/local/apache2/bin/apachectl restart
You still haven't solved the problem, however. Another safeguard in place makes this a forbidden action. So, you have to modify the permissions of all directories in the path to the desired destination:
cd ~ chmod a+rx ~/Documents/ chmod a+rx ~/Documents/workspaces/ chmod a+rx ~/Documents/workspaces/mmapp/
Essentially, you are updating the permissions so that Apache can "execute" along the directory paths to the directory where the website resides.
Now, you can navigate to http://localhost/mm
in your browser, and it will work just fine!