After reading through various tutorials [1] I still can't get my VirtualHost settings to work as desired. I'm getting a 403 Forbidden
when I try to use a VirtualHost with a directory below my user directory as its DocumentRoot
.
What I've done so far
Created file
/etc/apache2/sites-available/workspace
with following content:NameVirtualHost *:80 <VirtualHost *:80> ServerName project-site DocumentRoot /home/user/Workspace/project/site </VirtualHost>
Edited file
/etc/hosts
now yielding:127.0.0.1 localhost 127.0.1.1 my-machine # The following lines are desirable for IPv6 capable hosts ::1 ip6-localhost ip6-loopback fe00::0 ip6-localnet ff00::0 ip6-mcastprefix ff02::1 ip6-allnodes ff02::2 ip6-allrouters # VirtualHosts added by me 127.0.0.1 project-site
Enabled virtual hosts using
sudo a2ensite workspace
- Restarted Apache using
sudo services apache2 restart
- Tried opening
http://project-site
andhttp://project-site/test.html
(wheretest.html
is present in/home/user/Workspace/project/site/
) in my webbrowser
What happens
Restarting Apache I get the following messages on the command line:
* Restarting web server apache2 apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName [Sun May 13 10:33:37 2012] [warn] NameVirtualHost *:80 has no VirtualHosts [ OK ]
Opening either
http://project-site
orhttp://project-site/test.html
a "403 Forbidden" is served.
What should happen
I'd like to have the contents of /home/user/Workspace/project/site
being served when I browse to http://project-site
.
What I learned so far
From reading similar questions on this site I learned that this is probably a permission problem [2]. Files in /home/user/Workspace/project/site
might not be readable by www-data
. But how do I know or correct this?
Furthermore .htaccess
files were mentioned [3] being located in
/home/.htaccess
/home/user/.htacces
[...]
/home/user/path/to/project/.htaccess
and possibly not readable. I never created them, I don't want them, will I need them?
The second answer to another question [4] made me use NameVirtualHost
responsible for the warning on restart of Apache. Is it necessary and if, how do I use it properly?
Any help is much appreciated! Tell me, if you need to know anything else to locate the problem.
Ressources
http://www.thegeekstuff.com/2011/07/apache-virtual-host/, http://httpd.apache.org/docs/2.2/vhosts/name-based.html, http://mintarticles.com/read/software-articles/multiple-virtual-hosts-in-xampplampp-in-ubuntu,977/, http://www.pgorecki.pl/content/virtual-host-na-localho%C5%9Bcie-apache-ubuntu, ...
- Apache VirtualHost 403 Forbidden
- Ubuntu, Apache, virtualhost and Access forbidden
- VirtualHost configuration