Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

In a fresh linux instalation, apache's document root points to /var/www/html

user apache
group apache
DocumentRoot /var/www/html
<Directory /var/www/html>
# ...
</Directory>

I want my documentRoot points to "/home/myapp/release/1.0.0/src/public", so I've made this changes:

DocumentRoot /home/myapp/release/1.0.0/src/public
<Directory /home/myapp/release/1.0.0/src/public>
# ...
</Directory>

But now I'm getting the 'Forbidden' error message. So what is the correct way to configure permissions in order to resolve this issue in a production enviroment.

share|improve this question

migrated from stackoverflow.com Mar 3 '11 at 4:33

This question came from our site for professional and enthusiast programmers.

    
Does the apache user have read access to the target folder? /home/myapp/release/1.0.0/src/public –  kg_ Mar 2 '11 at 23:32
    
Does the apache user have read access to the target folder? If not, that is probably why Apache is giving you the Forbidden error message. –  kg_ Mar 2 '11 at 23:57

2 Answers 2

up vote 2 down vote accepted

I can think of two possible problems:

  1. Actual directory permissions are screwed up. This is fairly easy to test by changing to the user that Apache runs as and attempting to list that directory (assuming Apache is configured to run as "www-data"):

    sudo su -s /bin/sh www-data
    ls /home/myapp/release/1.0.0/src/public/
    

    If the Apache user does not have access, every directory in the path, starting from / will need to have read and execute permissions either for the Apache user or for "other":

    sudo chmod o+rx /home /home/myapp /home/myapp/release  /home/myapp/release/1.0.0 \
        /home/myapp/release/1.0.0/src /home/myapp/release/1.0.0/src/public
    
  2. You're trying to access a directory via Apache that does not contain an index file and you have not enabled "Indexes". This is also easy to test by looking to see if there is a file named index.html (or .php, .htm, etc.) in /home/myapp/release/1.0.0/src/public. If there is not, either add one or add Options +Indexes to the <Directory /home/myapp/release/1.0.0/src/public> block.

share|improve this answer

The apache user must have read permission in that directory. Also include these directives:

<Directory /home/myapp/release/1.0.0/src/public>
   # ...
   Order Allow,Deny
   Allow from all
</Directory>
share|improve this answer
    
These directives are already in the httpd.conf file How can I give correctly the required permissions?. I don't want to do a chmod 777 -Rf –  texai Mar 3 '11 at 2:40

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.