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.

I'm using Apache2 for completely local development purposes. I'm trying to make DocumentRoot to be /home/vikrant/www/ whereas permissions of /home/vikrant/ are 700.

I'm getting 403 Forbidden when DocumentRoot is /home/vikrant/www/ however It Works! when DocumentRoot is /var/www/.

I've even changed permissions of /home/vikrant/www/ to 777 and changed owner and group to www-data.

Is it possible to serve from home directory whereas home directory doesn't has public permissions? If yes, then how?

share|improve this question

3 Answers 3

Link your /Var/www/ to your home wikrant www and make sure the apache daemon owner has read permisions on that folder.

ln -s /home/vikrant/www /var/www/vikrant chmod -R g+w /var/www/vikrant

ls -alt /var/www/vikrant # check which group is the owner.

ps axu|grep apache2 # check the owner of the apache daemon.

add the owner of the apache daemon to the group which owns the /var/www/vikrant files.

share|improve this answer
    
It still didn't work. –  Vikrant Chaudhary Mar 17 '10 at 11:23
    
which user is running apache? #lets call it apache_user# can you do login as apache_user through root? > sudo su > su apache_user then use cat and ls to check if it can read your files. it is possible that you need to add +x to the directories previous to your files. –  marc.riera Mar 17 '10 at 11:34

You need at least 711 permissions on /home/vikrant. A user has to have execute rights (+x or 1) on a directory to access anything under it.

share|improve this answer

Check your configuration a bit deeper. Your default Apache setup is probably installed as simply not allow traffic to /. For that matter, it's probably only configured to allow traffic to /var/www.

In addition to setting directory permissions (and as the dude above me said, you'll need at least execute on other to traverse the directory), you want to make sure that you have something like the following configured:


    
        Options Indexes FollowSymLinks MultiViews
        AllowOverride all
        Order allow,deny
        allow from all
    

If you follow the above solution and just create a symbolic link from /var/www back to your home directory, you'll need to make sure Apache has been told that it's okay to follow symbolic links, by adding FollowSymLinks to the Options stanza for your existing document root.

Lastly, if you're using CGI under suExec, the symbolic link is your best bet as suExec has a compiled in "safe" path. There's an easy way around that if you're using a Debian distro, though.

Yet another approach would be to just define a new name based virtual host that points to your home directory.

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.