在阅读了各种教程 [1] 之后,我仍然无法让我的 VirtualHost 设置按预期工作。当我403 Forbidden尝试将 VirtualHost 与我的用户目录下的目录用作其DocumentRoot.
到目前为止我所做的
创建的文件
/etc/apache2/sites-available/workspace具有以下内容:NameVirtualHost *:80 <VirtualHost *:80> ServerName project-site DocumentRoot /home/user/Workspace/project/site </VirtualHost>编辑后的文件
/etc/hosts现在产生: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启用虚拟主机使用
sudo a2ensite workspace- 使用重新启动 Apache
sudo services apache2 restart - 尝试在我的网络浏览器中打开
http://project-site和http://project-site/test.html(在哪里test.html存在)/home/user/Workspace/project/site/
发生什么了
重新启动 Apache 我在命令行上收到以下消息:
* 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 ]打开
http://project-site或http://project-site/test.html提供“403 Forbidden”。
应该发生什么
/home/user/Workspace/project/site当我浏览到http://project-site.
到目前为止我学到了什么
通过阅读此站点上的类似问题,我了解到这可能是权限问题 [2]。中的文件/home/user/Workspace/project/site可能无法被www-data. 但我怎么知道或纠正这一点?
此外.htaccess,文件被提到 [3] 位于
/home/.htaccess
/home/user/.htacces
[...]
/home/user/path/to/project/.htaccess
并且可能不可读。我从未创造过它们,我不想要它们,我会需要它们吗?
另一个问题 [4] 的第二个答案让我NameVirtualHost负责 Apache 重启时的警告。是否有必要,如果,我该如何正确使用它?
任何帮助深表感谢!告诉我,如果您需要知道任何其他信息来定位问题。
资源
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 被禁止
- Ubuntu、Apache、虚拟主机和访问被禁止
- 虚拟主机配置