Wednesday, 6 October 2010

Allowing SymLinks in Mac OSX Web Sharing

The Web Sharing feature in Mac OSX allows you to share a folder in your home directory via Apache.
What I often want to do is to temporarily share a web site or suchlike that I'm currently working on, so I can access it via my iPhone for on-device testing. So what I wanted to do was to create a symlink from my ~/USERNAME/Sites folder to the actual folder where I'm working.

However, by default, any SymLinks within Sites not be followed due to the apache configuration. Happily this can be easily fixed.

Edit the file at:

/private/etc/apache2/users/USERNAME.conf


Which by default looks like this:

Directory "/Users/USERNAME/Sites/"
Options Indexes MultiViews
AllowOverride None
Order allow,deny
Allow from all
/Directory


To add the FollowSymLinks option. So the file should look like this:

Directory "/Users/USERNAME/Sites/"
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
/Directory


Then all you need to do is restart apache and you are done!

From the terminal type:

sudo apachectl graceful

No comments:

Post a Comment