Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fixing 403 Forbidden on alias directory with Apache

I am trying to setup an alias to point to some directory on my filesystem not in DocumentRoot. Now I get a 403 Forbidden response. These are the steps taken: 1. edit http.conf, adding:

Alias /example "/Users/user/Documents/example" 

then...

<Directory "/Users/user/Documents/example">    Options Indexes FollowSymLinks MultiViews    AllowOverride None    Order allow,deny    Allow from all</Directory> 

2. setting permissions with chmod in terminal:

chmod 755 /Users/user/Documents/example 

Now it should work? instead I get the access forbidden. This is the output from error_log:

[Sun Jul 24 06:57:57 2011] [error] [client xx.xx.xx.xx] (13)Permission denied: access to /example denied 
like image 920
sjking Avatar asked Jul 24 '11 14:07

sjking


People also ask

What is 403 Forbidden And how do you fix it?

A 403 error occurs when a server won't allow you to access a webpage. You can't always fix a 403 error on your own, but simple tricks like refreshing your page or clearing your cache could help. If visitors to your webpage are getting 403 errors, you may have to reconfigure it.


2 Answers

The last straw ;) Required local in the Directory Entry...

like

<Directory "/Users/user/Documents/example">    Options Indexes FollowSymLinks MultiViews    AllowOverride All    Require local    Order allow,deny    Allow from all </Directory> 

if everything else doesn't work (correct Alias, Directory Entry in httpd.conf and correct mod/usr/grp).

keep in mind: if you put your site in user-space the apache user (running httpd) needs access to your home!

like image 29
Mirco Ellmann Avatar answered Oct 14 '22 17:10

Mirco Ellmann


I was having this issue on OS X too. It turned out gliptak was right, but I've some more detail to add.

We're both attempting to configure a virtual directory for a folder under a user's home folder; I think this is why we're having the problem. In my case, I had the following setup:

  • Home folder is /Users/calrion.
  • Virtual directory folder is /Users/calrion/Path/to/www.
  • There's a symlink /Users/calrion/Path pointing to /Volumes/Other/Users/calrion/Path.

The problem was the user and group _www (which Apache runs as on OS X) lacked execute access to /Users/calrion and /Volumes/Other/Users/calrion.

Running chmod o+x /Users/calrion and chmod o+x /Volumes/Other/Users/calrion resolved the issue (on OS X 10.7.4).

The rule here is that Apache requires execute access to all folders in the path in order to serve files. Without this, you'll get a HTTP 403 (forbidden).

like image 153
Calrion Avatar answered Oct 14 '22 16:10

Calrion