Link to home
Start Free TrialLog in
Avatar of Rohit Singh, PMP
Rohit Singh, PMP

asked on

Apache - Forbidden error while accessing http://localhost/~user

Wanted to provide each Linux user a website, but even after enabling the same in httpd.conf viz the following:
================================
<IfModule mod_userdir.c>
#UserDir disabled
UserDir public_html
</IfModule>

<Directory /home/*/public_html>
    AllowOverride FileInfo AuthConfig Limit
    Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
    <Limit GET POST OPTIONS>
        Order allow,deny
        Allow from all
Deny from none
    </Limit>

</Directory>
============================================

File permissions also looks ok:
-----------------------------------------------------
[root@localhost rohit]# pwd
/home/rohit
[root@localhost rohit]# ls -lrt
total 8
drwxr-xr-x  2 apache apache 4096 Jan 19 21:39 public_html

[root@localhost rohit]# cd public_html/
[root@localhost public_html]# ls -lrt
total 8
-rwxr-xr-x  1 apache apache 37 Jan 19 21:39 index.html
-------------------------------------------------------------------

But on accessing the url http://localhost/~rohit, I am still getting the 403 Forbidden error as follows:
=================================
Forbidden

You don't have permission to access /~rohit on this server.

Additionally, a 403 Forbidden error was encountered while trying to use an ErrorDocument to handle the request.
Apache/2.0.52 (Red Hat) Server at 192.168.63.128 Port 80
=================================

httpd.conf is also attached for your perusal and also note that the other virtual hosts configured are working fine but the above is giving error.
httpd.conf.txt
Avatar of fosiul01
fosiul01
Flag of United Kingdom of Great Britain and Northern Ireland image

HI ya

you are trying to access  : http://localhost/rohit 

wel ,,

do you have to folder call rohit
in /var/www/html/  

also can you post the

ls -l out put in /var/www/html

need to check the permission for rohit folder
Avatar of Rohit Singh, PMP
Rohit Singh, PMP

ASKER

Hi Fosi,
Please look at the <Directory /home/*/public_html> from httpd.conf, I am trying to acces
http://localhost/~rohit which will call index.html from /home/rohit/public_html folder.

The output of the above is posted in the question. Kindly have a look again and appreciate your help.
what can you find in your error.log?


Not related,
> Deny from none

That is not an good idea. This causes a DNS lookup for the hostname 'none'. Simply remove the directive and reverse the Order directive.

Order deny,allow
no, I think you got something wrong

if you place any index.html in /var/ww/html directory

now if you type : http://localhost

that index.html will show up instead of default apache page

if you type : http://localhost  [ what page do you see ??]

now if you type : http://localhost/rohit/

so apache will try to look for index.html or index.php from /var/www/html/rohit/     [Directory]

now if you dont have that directory or if you dont have permission on that directory , apache will show permission denyed

here nothing to do with public_html

apache will look the directory from /var/www/html

you can comment out thsese lines

<Directory /home/*/public_html>
    AllowOverride FileInfo AuthConfig Limit
    Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
    <Limit GET POST OPTIONS>
        Order allow,deny
        Allow from all
Deny from none
    </Limit>

</Directory>
Content of error_log is as follows:

=========================
[Tue Jan 20 00:20:09 2009] [error] [client 192.168.63.1] (13)Permission denied: access to /~rohit denied
[Tue Jan 20 00:20:10 2009] [error] [client 192.168.63.1] (13)Permission denied: access to /~rohit denied
[Tue Jan 20 00:20:10 2009] [error] [client 192.168.63.1] (13)Permission denied: access to /~rohit denied
=========================

I have tried accessing the same on the linux server using IP but still no use. Appreciate your help.
Avatar of Maciej S
Check for permissions of that home directory itself (/home/rohit). It should have at least x permission for apache user (or for others).
Probably chmod o+x /home/rohit should be enough to make it work.
Hi Fosi,
It seems you got confused, I am not trying to access /var/www/html but instead of that have allowed for public_html which is not working.
yes, you are true, i am confused!!! sorry for that,
as Olkit said,
you need to change permission for /home/rohit
Hi Oklit,
As posted in the question, the file permission looks ok:

File permissions also looks ok:
-----------------------------------------------------
[root@localhost rohit]# pwd
/home/rohit
[root@localhost rohit]# ls -lrt
total 8
drwxr-xr-x  2 apache apache 4096 Jan 19 21:39 public_html

[root@localhost rohit]# cd public_html/
[root@localhost public_html]# ls -lrt
total 8
-rwxr-xr-x  1 apache apache 37 Jan 19 21:39 index.html
-------------------------------------------------------------------

But its not working and I am still getting 403 error.
Yes, I can see, what are the permissions for the content of /home/rohit. I wrote about permission of /home/rohit itself.
Please post here output of: ls -ld /home/rohit
Hi Oklit,
Thanks for your time, please find the output :

[root@localhost logs]# ls -ld /home/rohit
drwxr-xr-x  3 apache apache 4096 Jan 19 23:55 /home/rohit
What about SELinux?
Hi Caterham,
I am using RedHat Linux.
ASKER CERTIFIED SOLUTION
Avatar of fosiul01
fosiul01
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi Fosi,
Thanks a lot, I will try this and update you.
Hi Fosi,
Thanks a lot for your help, your solution worked for me but I also had to disable selinux after which it's working fine.

With regards,
Rohit
Apart from removing the Directives as advised by you, I also had to disable the selinux.