WampServer v2.5 上线403错误禁止访问
WampServer v2.5 Put Online 403 Error Forbidden
我下载了 wampserver 来创建我们的 php 应用程序,并且我已经在我的主机文件中设置了我的域 thesis.dev
。我的队友在我们的项目中工作,我们从我的调制解调器路由器共享 wifi。我正在尝试将我们的项目上线,以便他们也可以访问我的项目以查看创建的网站,但我的朋友们收到了这个:
403 Forbidden Error Message
这是我的主机文件:
# Copyright (c) 1993-2009 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
# 102.54.94.97 rhino.acme.com # source server
# 38.25.63.10 x.acme.com # x client host
# localhost name resolution is handled within DNS itself.
# 127.0.0.1 localhost
# ::1 localhost
127.0.0.1 localhost
127.0.0.1 project.dev
::1 localhost
::1 project.dev
这是我的 httpd-vhosts.conf 文件:
# Virtual Hosts
#
# Required modules: mod_log_config
# If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them. Most configurations
# use only name-based virtual hosts so the server doesn't need to worry about
# IP addresses. This is indicated by the asterisks in the directives below.
#
# Please see the documentation at
# <URL:http://httpd.apache.org/docs/2.4/vhosts/>
# for further details before you try to setup virtual hosts.
#
# You may use the command line option '-S' to verify your virtual host
# configuration.
#
# 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 "c:/Apache24/docs/dummy-host.example.com"
ServerName dummy-host.example.com
ServerAlias www.dummy-host.example.com
ErrorLog "logs/dummy-host.example.com-error.log"
CustomLog "logs/dummy-host.example.com-access.log" common
</VirtualHost>
<VirtualHost *:80>
ServerAdmin webmaster@dummy-host2.example.com
DocumentRoot "c:/Apache24/docs/dummy-host2.example.com"
ServerName dummy-host2.example.com
ErrorLog "logs/dummy-host2.example.com-error.log"
CustomLog "logs/dummy-host2.example.com-access.log" common
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "c:\wamp\www"
ServerName localhost
ServerAlias localhost
<Directory c:\wamp\www>
AllowOverride All
Require local
</Directory>
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "d:\Documents\Programs\Websites\thesis\public"
ServerName thesis.dev
ServerAlias thesis.dev
<Directory d:\Documents\Programs\Websites>
AllowOverride All
Require local
</Directory>
</VirtualHost>
我的 Apache 版本:2.4.9。我的 MySQL 版本:5.6.17。我的 PHP 版本:5.5.12
我的 IP 地址是 192.168.1.2。
我的朋友们试图在浏览器上访问 192.168.1.2 但出现 403 错误。
好的,这里有几件事
首先从 httpd-vhost.conf 文件中删除这 2 个条目。它们只是为帮助人们入门而提供的示例条目。如果您注意到它们指向您实际上不应该拥有的文件夹,即 C:/Apache24
等
<VirtualHost *:80>
ServerAdmin webmaster@dummy-host.example.com
DocumentRoot "c:/Apache24/docs/dummy-host.example.com"
ServerName dummy-host.example.com
ServerAlias www.dummy-host.example.com
ErrorLog "logs/dummy-host.example.com-error.log"
CustomLog "logs/dummy-host.example.com-access.log" common
</VirtualHost>
<VirtualHost *:80>
ServerAdmin webmaster@dummy-host2.example.com
DocumentRoot "c:/Apache24/docs/dummy-host2.example.com"
ServerName dummy-host2.example.com
ErrorLog "logs/dummy-host2.example.com-error.log"
CustomLog "logs/dummy-host2.example.com-access.log" common
</VirtualHost>
其次,当您开始使用虚拟主机时,Put Online
和 Put Offline
变得多余。您的 Apache 安全性现在包含在每个 VirtualHosts 定义中。因此,如果你想向本地网络上的其他人开放你的 thesis.dev
站点,即其他人通过 wifi 共享你的路由器,你需要告诉 Apache 这是允许的,所以像这样更改这个 VH 定义:-
<VirtualHost *:80>
DocumentRoot "d:\Documents\Programs\Websites\thesis\public"
ServerName thesis.dev
ServerAlias www.thesis.dev
<Directory "d:\Documents\Programs\Websites">
AllowOverride All
Require local
Require ip 192.168.1
</Directory>
</VirtualHost>
注意我添加了这一行
Require ip 192.168.1
例如,您需要做的就是检查您的路由器 DHCP 服务器是否在子网 192.168.1 中提供 IP 地址,这是家用路由器的标准,但您的可能不同。
从命令行运行检查你的
ipconfig
然后检查这一行
IPv4 Address. . . . . . . . . . . : 192.168.1.11
并使用 4 个四分位数中的前 3 个允许任何使用您的内部网络访问该网站的人。
我下载了 wampserver 来创建我们的 php 应用程序,并且我已经在我的主机文件中设置了我的域 thesis.dev
。我的队友在我们的项目中工作,我们从我的调制解调器路由器共享 wifi。我正在尝试将我们的项目上线,以便他们也可以访问我的项目以查看创建的网站,但我的朋友们收到了这个:
403 Forbidden Error Message
这是我的主机文件:
# Copyright (c) 1993-2009 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
# 102.54.94.97 rhino.acme.com # source server
# 38.25.63.10 x.acme.com # x client host
# localhost name resolution is handled within DNS itself.
# 127.0.0.1 localhost
# ::1 localhost
127.0.0.1 localhost
127.0.0.1 project.dev
::1 localhost
::1 project.dev
这是我的 httpd-vhosts.conf 文件:
# Virtual Hosts
#
# Required modules: mod_log_config
# If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them. Most configurations
# use only name-based virtual hosts so the server doesn't need to worry about
# IP addresses. This is indicated by the asterisks in the directives below.
#
# Please see the documentation at
# <URL:http://httpd.apache.org/docs/2.4/vhosts/>
# for further details before you try to setup virtual hosts.
#
# You may use the command line option '-S' to verify your virtual host
# configuration.
#
# 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 "c:/Apache24/docs/dummy-host.example.com"
ServerName dummy-host.example.com
ServerAlias www.dummy-host.example.com
ErrorLog "logs/dummy-host.example.com-error.log"
CustomLog "logs/dummy-host.example.com-access.log" common
</VirtualHost>
<VirtualHost *:80>
ServerAdmin webmaster@dummy-host2.example.com
DocumentRoot "c:/Apache24/docs/dummy-host2.example.com"
ServerName dummy-host2.example.com
ErrorLog "logs/dummy-host2.example.com-error.log"
CustomLog "logs/dummy-host2.example.com-access.log" common
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "c:\wamp\www"
ServerName localhost
ServerAlias localhost
<Directory c:\wamp\www>
AllowOverride All
Require local
</Directory>
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "d:\Documents\Programs\Websites\thesis\public"
ServerName thesis.dev
ServerAlias thesis.dev
<Directory d:\Documents\Programs\Websites>
AllowOverride All
Require local
</Directory>
</VirtualHost>
我的 Apache 版本:2.4.9。我的 MySQL 版本:5.6.17。我的 PHP 版本:5.5.12
我的 IP 地址是 192.168.1.2。
我的朋友们试图在浏览器上访问 192.168.1.2 但出现 403 错误。
好的,这里有几件事
首先从 httpd-vhost.conf 文件中删除这 2 个条目。它们只是为帮助人们入门而提供的示例条目。如果您注意到它们指向您实际上不应该拥有的文件夹,即 C:/Apache24
等
<VirtualHost *:80>
ServerAdmin webmaster@dummy-host.example.com
DocumentRoot "c:/Apache24/docs/dummy-host.example.com"
ServerName dummy-host.example.com
ServerAlias www.dummy-host.example.com
ErrorLog "logs/dummy-host.example.com-error.log"
CustomLog "logs/dummy-host.example.com-access.log" common
</VirtualHost>
<VirtualHost *:80>
ServerAdmin webmaster@dummy-host2.example.com
DocumentRoot "c:/Apache24/docs/dummy-host2.example.com"
ServerName dummy-host2.example.com
ErrorLog "logs/dummy-host2.example.com-error.log"
CustomLog "logs/dummy-host2.example.com-access.log" common
</VirtualHost>
其次,当您开始使用虚拟主机时,Put Online
和 Put Offline
变得多余。您的 Apache 安全性现在包含在每个 VirtualHosts 定义中。因此,如果你想向本地网络上的其他人开放你的 thesis.dev
站点,即其他人通过 wifi 共享你的路由器,你需要告诉 Apache 这是允许的,所以像这样更改这个 VH 定义:-
<VirtualHost *:80>
DocumentRoot "d:\Documents\Programs\Websites\thesis\public"
ServerName thesis.dev
ServerAlias www.thesis.dev
<Directory "d:\Documents\Programs\Websites">
AllowOverride All
Require local
Require ip 192.168.1
</Directory>
</VirtualHost>
注意我添加了这一行
Require ip 192.168.1
例如,您需要做的就是检查您的路由器 DHCP 服务器是否在子网 192.168.1 中提供 IP 地址,这是家用路由器的标准,但您的可能不同。
从命令行运行检查你的
ipconfig
然后检查这一行
IPv4 Address. . . . . . . . . . . : 192.168.1.11
并使用 4 个四分位数中的前 3 个允许任何使用您的内部网络访问该网站的人。