我在Ubuntu 13上运行Apache 2.4.6。
在可用的网站中,我的网站的conf文件只包含以下内容:
<VirtualHost *:80>
# Admin email, Server Name (domain name), and any aliases
ServerAdmin somebody@somewhere.com
ServerName www.ourco.me
ServerAlias ourco.me
# Index file and Document Root (where the public files are located)
DirectoryIndex index.html index.php
DocumentRoot /home/ouruser/public/ourco.me/public
# Log file locations
LogLevel warn
ErrorLog /home/ouruser/public/ourco.me/log/error.log
CustomLog /home/ouruser/public/ourco.me/log/access.log combined
</VirtualHost>
没有启用其他配置文件。当我使用apachectl -S显示网站时,它会显示:
VirtualHost configuration:
*:80 is a NameVirtualHost
default server www.ourco.me (/etc/apache2/sites-enabled/ourco.me.conf:1)
port 80 namevhost www.ourco.me (/etc/apache2/sites-enabled/ourco.me.conf:1)
alias ourco.me
port 80 namevhost www.ourco.me (/etc/apache2/sites-enabled/ourco.me.conf:1)
alias ourco.me
ServerRoot: "/etc/apache2"
Main DocumentRoot: "/var/www"
Main ErrorLog: "/var/log/apache2/error.log"
Mutex watchdog-callback: using_defaults
Mutex default: dir="/var/lock/apache2" mechanism=fcntl
Mutex mpm-accept: using_defaults
PidFile: "/var/run/apache2/apache2.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
User: name="www-data" id=33
Group: name="www-data" id=33
我注意到的第一件事是namevhost www.ourco.me的重复条目。当我在浏览器中访问该网站时,我得到:
您无权访问此服务器上的/。
Apache / 2.4.6(Ubuntu)服务器,网址为www.ourco.me端口80
存在conf文件中指定的所有目录和文件。 a2ensite和a2dissite按预期工作,从已启用站点的文件中添加/删除此文件的符号链接,因此它正在查看正确的文件。有谁知道为什么它的指令被忽略了?感谢。
答案 0 :(得分:1)
Put Allow from all
<VirtualHost *:80>
# Admin email, Server Name (domain name), and any aliases
ServerAdmin somebody@somewhere.com
ServerName www.ourco.me
ServerAlias ourco.me
# Index file and Document Root (where the public files are located)
DirectoryIndex index.html index.php
DocumentRoot /home/ouruser/public/ourco.me/public
# Log file locations
LogLevel warn
ErrorLog /home/ouruser/public/ourco.me/log/error.log
CustomLog /home/ouruser/public/ourco.me/log/access.log combined
Allow from all
</VirtualHost>
答案 1 :(得分:1)
这似乎可以解决问题:
<Directory />
Require all granted
</Directory>
放入VirtualHost条目时。
该片段来自this post。我正在查看this Apache doc以了解其工作原理。