Creating a symbolic link in Sites directory

MacosApache2

Macos Problem Overview


I have a file in my ~/Sites directory that works fine when I browse to it through coderama.local/~coderama/index2.php

Now I want to get tricky and move my index2.php file to somewhere else on my system, so I do this by creating a symbolic link. However, when I try to access coderama.local/~coderama/index2.php I now get the following error.

Any ideas anyone?

Thanks!

> ### Forbidden > You don't have permission to access /~coderama/index2.php on this server.

Macos Solutions


Solution 1 - Macos

That's a configurable Apache option. It appears that by default on Macs (and probably most installations) Apache is configured to not follow symbolic links. I'm guessing (as others mention above) that it's for security purposes.

But it can be really convenient at times to enable following of symbolic links, particularly during development of certain kinds of apps. What you need to do is 1) change the Apache configuration to allow the following of symbolic links, and then 2) restart Apache.

The configuration step is performed as follows:

a) cd /etc/apache2 (this is where Apache's configuration files are by default on a Mac)

b) you'll see a couple of directories here. One is called users

c) cd users

d) ls should reveal a .conf file with your login name (login.conf) I'm "marvo" so mine is named "marvo.conf"

e) Edit this file (I use vi) -- but you have to do it using sudo:

sudo vi marvo.conf

f) You'll see something like

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

g) Add the "FollowSymLinks" option so that the second line of that .conf file looks like:

Options Indexes MultiViews FollowSymLinks

(You can find other configuration options out there on the 'net. I found this page: http://httpd.apache.org/docs/2.0/mod/core.html#directory )

h) Save the file.

Now you have to restart Apache so that it picks up the configuration change. Googling around a bit, I found that this is most easily done from the command line with the following command:

sudo /usr/sbin/apachectl restart

(Found that at http://mcapewell.wordpress.com/2006/09/22/restart-apache-in-mac-os-x/ )

Now that symbolic link should work just fine on your Sites pages.

Solution 2 - Macos

Had the same issue. Unfortunately, Marvo's answer wasn't enough.

The problem lies with the permissions set on every folder in the path, starting from ~/. The directories needs the execute flag set to be able to recurse the directory tree. So, in my case, I symlinked a theme folder from ~/Dropbox/projects/theme to a wordpress install on ~/Site/wordpress.

The answer was:

chmod a+x ~/Dropbox/
chmod a+rx ~/Dropbox/projects

This is an old issue, but if anyone reaches this page, it might be useful. :)

Solution 3 - Macos

Seems like a security issue (also suggested by Matt)

http://discussions.apple.com/thread.jspa?threadID=1771399

Solution 4 - Macos

I don't remember the specific reason why, but it doesn't work. It's a security issue. You can use XAMPP <http://www.apachefriends.org/en/xampp-macosx.html> or MAMP <http://www.mamp.info/en/index.html> to get around this.

Solution 5 - Macos

In addition to Marvo's answer. What helped me was to Change the permission on Documents folder:

cd ~
chmod a+rx Documents/

Solution 6 - Macos

Also make sure you have a directive in your httpd-vhosts.conf

Otherwise you get the same '403 forbidden in the browser', with 'the client denied by server configuration in the error log.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionCoderamaView Question on Stackoverflow
Solution 1 - MacosMarvoView Answer on Stackoverflow
Solution 2 - MacosagarieView Answer on Stackoverflow
Solution 3 - MacosCoderamaView Answer on Stackoverflow
Solution 4 - MacosMatt WilliamsonView Answer on Stackoverflow
Solution 5 - MacosGal BrachaView Answer on Stackoverflow
Solution 6 - MacossnowboundView Answer on Stackoverflow