About My Blog



Whenever I get stuck doing something - the time comes to venture in the world of internet to find solution. In most cases I do find the solution, solve my problem and go on with my life. Then one day I am faced with the same problem. But now - I can't remember how the hell I solved it the first time. So the cycle begins again. Then I thought, what if I can remember all the those things? So here it is, my Auxiliary Memory. I decided to save all the problems and their solution in this blog so that I can get back to them when I need them. And the plus point is - so can everybody else.

Thursday, October 30, 2014

You don't have permission error in Apache in CentOS

The Problem

I have installed apache 2.2 in centos 6. Everything worked fine when the apache folder was at its default location /var/www/html. Then I configured a Virtual host inside my users home folder. After that apache started showing Forbidden You don't have permission error when I tried to go to localhost or 127.0.0.1 from browser. this is the code i used in httpd.conf
<VirtualHost *:80>
        DocumentRoot "/home/anjan/workspace/mfs"
        ServerName anjan-centOS
        <Directory "/home/anjan/workspace/mfs">
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Order Deny,Allow
                Allow from all
        </Directory>
</VirtualHost>

I also disabled SElinux as was mentioned in some articles but in vain. If anyone could help me out it would be much appreciated.

The Solution

I solved the problem. After meddling with the permission of the system I found out that the user "anjan" who is owner of /home/anjan had read/write/execute permission on /home/anjan but the group "anjan", created when user "anjan" was created didn't have any permission at all.
ls -l /home/
showed
drwx------. 28 anjan anjan 4096 Jan 21 13:19 anjan
so I changed the permission with this command
chmod -R 770 /home/anjan
ls -l /home/
drwxrwx---. 28 anjan anjan 4096 Jan 21 13:19 anjan
i found out under which user my apache is running from this thread. It was running under user "apache" so I added user "apache" to group "anjan" with this command.
usermod -G anjan,apache apache
after that voila. No more Forbidden error.

No comments:

Post a Comment