【问题标题】:Error apache : access denied错误 apache:访问被拒绝
【发布时间】:2016-09-18 14:46:36
【问题描述】:

我的配置:

Wampserver 3.0.0 32 位 阿帕奇 2.4.17 php 5.6.15 mysql 5.7.9

我的问题: WampServer 正常启动,但是当我尝试访问日志中的项目时,我有:


[Sat May 21 10:55:39.393866 2016] [authz_core:error] [pid 6984:tid 1140] [client 127.0.0.1:50070] AH01630: client denied by server configuration: C:/wamp/www/project/api/app/

[Sat May 21 10:55:39.395878 2016] [authz_core:error] [pid 6984:tid 1140] [client 127.0.0.1:50070] AH01630: client denied by server configuration: C:/wamp/www/project/api/src/

但我检查了我的配置文件,一切似乎都正常。

有我的配置文件:

httpd.conf:

<Directory "C:/wamp/www/">
#
# 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
# [httpd.apache.org]
# for more information.
#
Options Indexes FollowSymLinks

#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# AllowOverride FileInfo AuthConfig Limit
#
AllowOverride all

#
# Controls who can get stuff from this server.
#

#onlineoffline tag - don't remove
#Require local
Require all granted
</Directory>


httpd-vhosts.conf:

<VirtualHost *:80>
ServerAdmin admin@test.fr
ServerName localhost
DocumentRoot "C:/wamp/www"
<Directory "C:/wamp/www">
Options +Indexes +FollowSymlinks
AllowOverride All
</Directory>
</VirtualHost>

<VirtualHost *:80>
ServerAdmin admin@test.fr
ServerName localhost.project.com
#ServerAlias localhost.project.com
DocumentRoot "C:/wamp/www/project/website/web/"
<Directory "C:/wamp/www/project/website/web/">
Options +Indexes +FollowSymlinks
AllowOverride All
</Directory>
</VirtualHost>

<VirtualHost *:80>
ServerAdmin admin@test.fr
DocumentRoot "C:/wamp/www/project/api"
ServerName api.project.com
#ServerAlias api.project.com
<Directory "C:/wamp/www/project/api">
Options +Indexes +FollowSymlinks
AllowOverride All
</Directory>
</VirtualHost>

<VirtualHost *:80>
ServerAdmin admin@test.fr
DocumentRoot "C:/wamp/www/Demo_websocket/web"
ServerName demo.websocket
#ServerAlias demo.websocket
<Directory "C:/wamp/www/Demo_websocket/web">
Options +Indexes +FollowSymlinks
AllowOverride All
</Directory>
</VirtualHost>

我的主机文件:

我想我不太明白你的意思。我的内容 主机文件是: 127.0.0.1 本地主机 127.0.0.1 api.project.com 127.0.0.1 localhost.project.com

我已经尝试在 VirtualHost 中设置 Require all grant 但没有成功:s

如果有人已经遇到过这个问题并找到了解决方案,我很感兴趣。谢谢

【问题讨论】:

  • 您在这里所做的是基于名称的虚拟主机。当您在 localhost 上进行测试时,这意味着您的主机文件应该将所有涉及的名称(localhost.project.com、api.project.com 和其他名称)解析为 127.0.0.1。并且,请求应该引用这些名称,因为没有将主机定义为默认值,当 Apache 收到地址为“127.0.0.1”的请求时,它不会知道是谁的意思。
  • 我希望不要说愚蠢的话,但我编辑我的消息以添加我的主机文件的内容。如果我明白你说的话,问题就出在那儿

标签: apache wamp wampserver


【解决方案1】:

您正在使用 localhost 和虚拟主机, 如果这是你的 hosts 文件,那就是正确的

127.0.0.1 localhost 
127.0.0.1 api.project.com 
127.0.0.1 localhost.project.com

在您的本地浏览器中,您将编写这些网址之一。

但是您的虚拟主机配置必须响应特定主机而不是 *,例如 fo api 您必须具有 &lt;VirtualHost api.project.com:80&gt; 而不是 &lt;VirtualHost *:80&gt;

还有通用的 * 虚拟主机必须在列表的末尾,那么结果是:

<VirtualHost localhost.project.com:80>
ServerAdmin admin@test.fr
ServerName localhost.project.com
#ServerAlias localhost.project.com
DocumentRoot "C:/wamp/www/project/website/web/"
<Directory "C:/wamp/www/project/website/web/">
Options +Indexes +FollowSymlinks
AllowOverride All
</Directory>
</VirtualHost>

<VirtualHost api.project.com:80>
ServerAdmin admin@test.fr
DocumentRoot "C:/wamp/www/project/api"
ServerName api.project.com
#ServerAlias api.project.com
<Directory "C:/wamp/www/project/api">
Options +Indexes +FollowSymlinks
AllowOverride All
</Directory>
</VirtualHost>

<VirtualHost demo.websocket:80>
ServerAdmin admin@test.fr
DocumentRoot "C:/wamp/www/Demo_websocket/web"
ServerName demo.websocket
#ServerAlias demo.websocket
<Directory "C:/wamp/www/Demo_websocket/web">
Options +Indexes +FollowSymlinks
AllowOverride All
</Directory>
</VirtualHost>

<VirtualHost *:80>
ServerAdmin admin@test.fr
ServerName localhost
DocumentRoot "C:/wamp/www"
<Directory "C:/wamp/www">
Options +Indexes +FollowSymlinks
AllowOverride All
</Directory>
</VirtualHost>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-01-15
    • 2010-10-24
    • 2012-12-21
    • 2010-12-23
    • 2017-06-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多