0

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.

2
  • obviously the fourth w in the chmod is a typo. Right?
    – Eineki
    Commented Nov 12, 2011 at 12:45
  • yeah... that sure is a typo
    – suenda
    Commented Nov 13, 2011 at 10:31

3 Answers 3

1

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 ...

0
2

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

1
  • 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
    Commented Nov 13, 2011 at 10:40
0

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>

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .