我在Mac OS 10.8中运行Apache,这是我的httpd.conf(其中的一部分):
DocumentRoot "/Library/WebServer/Documents"
#
# Each directory to which Apache has access can be configured with respect
# to which services and features are allowed and/or disabled in that
# directory (and its subdirectories).
#
# First, we configure the "default" to be a very restrictive set of
# features.
#
<Directory />
Options FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
#Allow from all
</Directory>
#
# Note that from this point forward you must specifically allow
# particular features to be enabled - so if something's not working as
# you might expect, make sure that you have specifically enabled it
# below.
#
#
# This should be changed to whatever you set DocumentRoot to.
#
<Directory "/Library/WebServer/Documents">
#
# Possible values for the Options directive are "None", "All",
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important. Please see
# http://httpd.apache.org/docs/2.2/mod/core.html#options
# for more information.
#
Options Indexes FollowSymLinks MultiViews
#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
AllowOverride All
#
# Controls who can get stuff from this server.
#
Order allow,deny
Allow from all
#Allow from 192.168.0.102
#Allow from 192.168.0.104
#Allow from ::1
#Allow from localhost
</Directory>
在<Directory />
中,如果我将Deny from all
更改为Allow from all
,则从我的设备访问时会获得Not found. The requested URL / was not found on this server
(在浏览器中测试ip:192.168.0.103,这是我的本地主机wifi ip)。但如果设置为Deny from all
,那么我会Forbidden
。我不知道如何解决这个问题。
提前致谢。
答案 0 :(得分:0)
好的,经过大量的调试后,我终于修好了。问题是我的httpd-vhosts.conf
文件:
#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for all requests that do not
# match a ServerName or ServerAlias in any <VirtualHost> block.
#
<VirtualHost *:80>
ServerAdmin webmaster@dummy-host.example.com
DocumentRoot "/usr/docs/dummy-host.example.com"
ServerName dummy-host.example.com
ServerAlias www.dummy-host.example.com
ErrorLog "/private/var/log/apache2/dummy-host.example.com-error_log"
CustomLog "/private/var/log/apache2/dummy-host.example.com-access_log" common
</VirtualHost>
我预先安装了这个虚拟主机。如果您阅读评论The first VirtualHost seection is usedfor all requests that do not match a ServerName or ServerAlias...
。所以我已将其删除,现在我的第一个虚拟主机是我自己的目录(它必须是第一个,之后你可以放置其他虚拟主机指令)。