Creating a symbolic link in a site directory

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

Now I want to get the trick and move my index2.php file to another location on my system, so I do this by creating a symlink. However, when I try to access coderama.local/~coderama/index2.php , I get the following error.

Any ideas anybody?

Thank!

Forbidden

You do not have permission to access /~coderama/index2.php on this server.

+57
apache2 macos
Sep 23 '10 at 2:44
source share
6 answers

This is a custom Apache parameter. It seems that by default on Mac computers (and possibly on most installations) Apache is configured to not follow symbolic links. I assume (as others mention above) that this is for security purposes.

But sometimes it can be very convenient to include the following symbolic links, especially when developing certain types of applications. What you need to do is 1) change the configuration of Apache to allow the following symbolic links, and then 2) restart Apache.

The configuration step is as follows:

a) cd / etc / apache2 (here Apache's default configuration files are on Mac)

b) here you will see a couple of directories. One of them is called by users.

c) cd users

d) ls should open the .conf file with your login name (login.conf). I am "marvo", so mine has the name "marvo.conf"

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

 sudo vi marvo.conf 

f) You will 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 this .conf file looks like this:

 Options Indexes MultiViews FollowSymLinks 

(You can find other configuration parameters on the network. I found this page: http://httpd.apache.org/docs/2.0/mod/core.html#directory )

h) Save the file.

Now you need to restart Apache so that it changes the configuration. Having caught a bit, I found that this is easiest to do from the command line with the following command:

 sudo /usr/sbin/apachectl restart 

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

Now that the symbolic link should work fine on the pages of your sites.

+100
Nov 23 '10 at 23:35
source share
— -

There was the same problem. Unfortunately, Marvo's answer was not enough.

The problem is the resolution set for each folder in the path, starting with ~/ . Directories need to set the execute flag in order to be able to regenerate the directory tree. So, in my case, I linked the themes folder from ~/Dropbox/projects/theme to installing wordpress on ~/Site/wordpress .

The answer was:

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

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

+55
Jun 29 2018-12-12T00: 00Z
source share

Sounds like a security issue (also suggested by Matt)

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

+5
Sep 23 '10 at 3:15
source share

I do not remember the specific reason, but it does not work. This is 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.

+1
Sep 23 '10 at 2:56
source share

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

 cd ~ chmod a+rx Documents/ 
+1
Jan 20 '13 at 1:17
source share

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

Otherwise, you will receive the same "403 ban in the browser", while "the client refused the server configuration in the error log."

0
Jun 05 '13 at 9:28
source share



All Articles