How to allow acces to a symbolic link in my ~/Sites/ for Apache under Mac OS X Lion 10.7.2

Here is a blog post I wrote when I was trying to figure out how to do exactly what you are trying to do.

  1. Enable Web Sharing on the MAC by going to System Prefrences —> Sharing —> Check Enable Web Sharing
  2. Edit your username.conf file located in /private/etc/apache2/users and add the “FollowSymLinks” directive:

    <Directory "/Users/yourUserName/Sites/">
        Options Indexes MultiViews FollowSymLinks
        AllowOverride None
        Order allow,deny
        Allow from all
    </Directory>
    
  3. Edit the /private/etc/apache2/httpd.conf file and make sure the line under “# Virtual hosts” is not commented out, like so:

    Include /private/etc/apache2/extra/httpd-vhosts.conf
    
  4. Edit the /private/etc/apache2/extra/httpd-vhosts.conf file and add:

    <VirtualHost *:80>  
        <Directory /Users/yourUserName/Sites/MyWebSite.com>
            Options +FollowSymlinks +SymLinksIfOwnerMatch
            AllowOverride All
        </Directory>
      DocumentRoot /Users/yourUserName/Sites/MyWebSite
      ServerName MyWebSite.local
    </VirtualHost>
    
  5. Edit the /etc/hosts file and add this at the top:

    127.0.0.1 MyWebSite.local
    
  6. Make a Symlink to link your Code directory to one in the Sites directory.

    ln -s ~/Code/MyWebSite ~/Sites/MyWebSite
    
  7. Restart apache


In fact only the first 2 steps from Emjay's answer plus an apache restart are necessary, here is what worked for me:

  1. Enable Web Sharing on the MAC by going to System Prefrences —> Sharing —> Check enabled Web Sharing

  2. Edit your username.conf file located in /private/etc/apache2/users and add the FollowSymLinks directive:

    <Directory "/Users/yourUserName/Sites/">
        Options Indexes MultiViews FollowSymLinks
        AllowOverride None
        Order allow,deny
        Allow from all
    </Directory>
    
  3. check your apache config

    sudo apachectl -t

  4. restart apache

    sudo apachectl restart

Now Apache will serve the symbolic links under your Sites directory.