2

Is there a way to symbolically link a directory using ln to my ~/Sites/ directory on OS X so that the permissions are correct so it may be viewed in a web browser when I'm doing web development on a local machine?

This is what I did ln -s ~/code/web/yolkportfolio ~/Sites/yolkportfolio I then chmod 755 on the directory but it still isn't readable.

Any help would be greatly appreciated.

slhck
  • 235,242
yolk
  • 141

2 Answers2

2

The problem was with my apache config. Here is what allowed it to work, just the FollowSymLinks rule.

<Directory "/Users/Joe/Sites/">
    Options Indexes MultiViews FollowSymLinks
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>
yolk
  • 141
0

You have a couple of options:

1. If you are running apache with a different user (not yours), and definitively want the DocumentRoot to point to some directory inside your home, you meed to change permissions to your home directory (defaults must be 750 or 700) to 755

I'd only recommend this if this is your laptop or your personal computer and no one else has access to it.

2. The first one is not an option but you still want the DocumentRoot inside your home, then you can change the user who runs apache. Edit its configuration file and look for directives User and Group.

3. Second one is still not an option, and still ... you want things inside your home. Use apache's mod_userdir. With the following configuration:

<IfModule mod_userdir.c>
        UserDir public_html
        UserDir disabled root

        <Directory /home/*/public_html>
                AllowOverride FileInfo AuthConfig Limit Indexes
                Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
                <Limit GET POST OPTIONS>
                        Order allow,deny
                        Allow from all
                </Limit>
                <LimitExcept GET POST OPTIONS>
                        Order deny,allow
                        Deny from all
                </LimitExcept>
        </Directory>
</IfModule>

This is the default configuration for Apache's mod_userdir on Debian. You will be able to access:

/home/your-username/public_html/*

on your browser at the following address:

http://somewhere/your-username/*

4. Finally, you could place DocumentRoot somewhere else (/srv/www, /opt/www or whatever) and setup permissions as needed.

Torian
  • 637