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

I am trying to change my DocumentRoot from APACHE_ROOT/htdoc to /home/user/www in Fedora 16. I am getting 403 Forbidden: You don't have permission to access / on this server.

I modified DocumentRoot in conf/httpd.conf as:

..
DocumentRoot "/home/user/www"
...

I changed my "www" permission with

chmod -R 777 www

I restarted apache server and i still get the error "you don't have permision to access / on this server"

I even tried setting off the SELinux as

echo 0 > /selinux/enforce

still the problem persists.

I think it's problem with the configuration file itself.. Is there any other parameters that need to be changed.

share|improve this question

migrated from stackoverflow.com Sep 19 '12 at 12:18

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

    
obviously the fourth w in the chmod is a typo. Right? –  Eineki Nov 12 '11 at 12:45
    
yeah... that sure is a typo –  suenda Nov 13 '11 at 10:31

3 Answers 3

up vote 1 down vote accepted

Stated that yo have to change the directory directive also, the path to your root

....
DocumentRoot /home/user/www
....
<Directory /home/user/www/>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    Order allow,deny
    allow from all
</Directory>

You should also tune better your permission policy to me ...

share|improve this answer
    
thanks.. for your answer. –  suenda Nov 13 '11 at 10:32

i'd recommend against using 777. First of all you need to find which user httpd/apache is set to run under. Usually its www-data or "nobody". It'll be in the main apache conf file ("httpd.conf" ?). I also get the group too and have any ftp developer accounts part of the apache group.

Then you just

chown -Rv nobody /home/user/www

where nobody is the apache user, or if you want to use the group too do

chown -Rv nobody:nogroup /home/user/www

Then i'd recommend setting your chmod to something more secure using

chmod -Rv 0775 /home/user/www

You will have to decide on the best chmod for yourself. If your using groups to manage who can edit the files then probably 775, if not then 755. I generally start everything with 644 and give additional permission where required. But that can be annoying on large systems

share|improve this answer
    
Thanks for the answer. I have had tried creating a new user apache2 under group www and I runned apache as apache2:www and also the changed the ownership of DocumentRoot to apache2:www. However, I still got the error. So, what I tried recently was running apache as root, which the server complaint as not a good practice.. Then, I tried running as user:user which is my primary account, and surprise it worked. I figured out what the problem was.. It was like my /home/user had permission 700. I wish I has thought about this before.. Anyway, I'd appreciate the helps –  suenda Nov 13 '11 at 10:40

Change SELinux context in terminal as root:

chcon -R -t httpd_user_content_t /home/user/www

Don't modify conf/httpd.conf. Create the file /etc/httpd/conf.d/mysites.conf and insert that content:

NameVirtualHost *:80
<VirtualHost *:80>
    ServerName localhost
    DocumentRoot /home/user/www
    <Directory /home/user/www>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        allow from all
    </Directory>
</VirtualHost>
share|improve this answer

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.