【发布时间】:2011-10-21 00:17:52
【问题描述】:
我最近尝试使用 Apache 设置测试服务器。该站点必须在域www.mytest.com 下运行。我总是收到403 Forbidden 错误。我在 Ubuntu 10.10 服务器版上。文档根目录位于/var/www 目录下。以下是我的设置:
/var/www 的内容
ls -l /var/www/
total 12
drwxr-xr-x 2 root root 4096 2011-08-04 11:26 mytest.com
-rwxr-xr-x 1 root root 177 2011-07-25 16:10 index.html
服务器上的主机文件内容(IP为192.168.2.5)
cat /etc/hosts
127.0.0.1 localhost
127.0.1.1 americano
192.168.2.5 americano.mytest.com www.mytest.com
# The following lines are desirable for IPv6 capable hosts
::1 localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
网站配置
<VirtualHost *>
ServerAdmin admin@mytest.com
ServerName www.mytest.com
ServerAlias mytest.com
DocumentRoot "/var/www/mytest.com"
ErrorLog /var/log/apache2/mytest-error_log
CustomLog /var/log/apache2/mytest-access_log combined
#
# This should be changed to whatever you set DocumentRoot to.
#
<Directory "/var/www/mytest.com">
Options -Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
我的文档根目录中没有.htaccess 文件。权限设置正确(www-data 可读)。
如果我从我的桌面输入 IP 地址,网站会正确显示。我将桌面上的主机文件更改为将www.mytest.com 指向服务器的IP。当我使用它时,我得到403。由于该站点的许多功能都对站点名称敏感,因此我必须能够通过域名访问该站点。
另一个奇怪的事情是,即使所有日志文件都正确创建,它们也没有关于此错误的信息。
我被困住了。有人可以帮忙吗?
【问题讨论】:
-
能否添加以下内容:
sudo sh -c ". /etc/apache2/envvars; apache2 -S"(虚拟主机列表)和:sudo sh -c ". /etc/apache2/envvars; grep -R Listen /etc/apache2/*|grep -v \"#\"; grep -R NameVirtual /etc/apache2/*|grep -v \"#\"" -
第一个命令返回如下:
VirtualHost configuration: 192.168.2.5:* www.mytest.com (/etc/apache2/sites-enabled/mytest.com:1) Syntax OK第二个返回:/etc/apache2/ports.conf:Listen 80 /etc/apache2/ports.conf: Listen 443 /etc/apache2/ports.conf: Listen 443 /etc/apache2/conf.d/virtual.conf:NameVirtualHost *
标签: linux apache ubuntu virtualhost http-status-code-403