Mac OS X, Web Sharing / Apache, and Symlinks

Mac OS X comes with an Apache installation which is very handy, but by default it’s configured not to follow symlinks. A lot of times I have projects in other directories which I want to share via the web server, but end up getting errors such as the following:


You don’t have permission to access /~tlrobinson/Editor/ on this server.

And in the error log file:

[Wed Jun 25 16:17:14 2008] [error] [client ::1] Symbolic link not allowed or link target not accessible: /Users/tlrobinson/Sites/Editor

To enable following of symlinks, edit your account’s configure file located at /private/etc/apache2/users/username.conf

Here’s the default:

Options Indexes MultiViews
AllowOverride None
Order allow,deny
Allow from all

You can either add “FollowSymLinks” to the Options directive (“Options Indexes MultiViews FollowSymLinks”), or change the AllowOverride directive to “All” (“AllowOverride None”) and place a .htaccess with it’s own Options directive (“Options FollowSymLinks”) in your Sites directory.

Then just restart Apache (“sudo apachectl graceful”) and symlinks should work.

  • Nathan

    Sweet this works… was looking all over for the answer to this. Thanks!

  • Ben Clayton

    Nice one – exactly what I wanted. Thanks!

  • Jonathan Dumaine

    Excellent. Thanks. I was wondering where the stupid conf files were for OS X’s install of apache.

  • jahroy

    Thank you thank you thank you thank you…

    Took me a couple hours to find this!

    SymLinks for Mac OS Apache were driving me crazy!

  • Richard Herries

    If this by chance like me still doesn’t work. Check out the following link. It apparently has to do with permissions as well. Or if you don’t like clicking on links put this into Terminal in your home directory ‘chmod a+rx Documents’ i.e. ~ username$
    However as stated above you will also need to allow Symlinks in your account directory.

  • enjalot

    thanks! exactly what i was looking for 🙂

  • Gustavo Neves

    As Richard Mentions, it all fails unless all directories in the path for the target directory have at least permission to read! This is very important and will get you nuts trying to make this work.

    Another thing one can do is to assign apache aliases (so you can use localhost/something directly).

    So wrapping it all up this is how I would explain it:

    $ represents terminal (should not be typed)
    gus represents my user folder

    So for example, I wanted to add access to:
    /Users/gus/Documents/Griffith/sem6/2622ICT/Lab exercises/

    So I had to:
    $ chmod 755 /Users/
    $ chmod 755 /Users/gus/
    $ chmod 755 /Users/gus/Documents/
    … and so on

    I have also done:
    $ chmod 755 /Users/gus/Documents/Griffith/sem6/2622ICT/Lab exercises/*
    as I want all folders inside that folder to be visible/openable.
    This way I can open any version I have there (each week I have a new lab done).

    I have also enabled symlinks and then I have actually used the symlink in my alias.
    $ cd /Users/gus/Sites
    $ ln -s /Users/gus/Documents/Griffith/sem6/2622ICT/Lab exercises/ flickmee

    And then my alias was defined at my “/private/etc/apache2/users/gus.conf” file:
    Alias /flickmee “/Users/gus/Sites/flickmee”

    Followed by:
    <Directory “/Users/gus/Sites/flickmee”>
        Options Indexes MultiViews
        AllowOverride None
        Order allow,deny
        Allow from all
    *You may also add the FollowSymLinks here if you need/want it inside this folder

    The procedure above makes it possible for me to access that flickmee symlink in 2 different ways:
    localhost/~gus/flickmee/ (because the symlink is located inside my Sites folder)
    localhost/flickmee/ (because of the Apache alias to the above symlink)

    you may check permissions by using:
    $ ls -la folder

    Pro-Tip: You can drag and drop folders on terminal and their full path will be parsed there.

    Cheers! XD

    • r2

      Thanks a lot ! I tried various stuff during 90 minutes before realizing I had to chmod a+rx ..

    • Rizky Syazuli

      that’s a lot of permissions to change. you sure it wont cause any security problems in the future?

  • Eduardo Cereto Carvalho

    Thanks for it. Really helpful.

  • Andy Woodly

    thanks, helped me quickly.

  • Luis Pulido

    Thanks-a-lot .. FollowSymLinks is the way.

  • Desai

    Thank you for this. Very helpful tip.

  • Corrigan Diseño Web

    Fantastic! Always a couple of niggling problems when you upgrade MacOS. This tip sorted out one of mine – Thanks!

  • Filippo Fadda

    For security reasons, use SymLinksIfOwnerMatch instead of FollowSymLinks.

  • Brian Henry

    Thank you so much. That was a frustrating couple of hours. I didn’t hold out much hope in a seven year old blog post helping, but putting the .htaccess file in my Sites folder sorted it for me. Much appreciated.