我下载了wampserver来创建我们的php应用程序,并且我已经在我的主机文件中设置了我的域thesis.dev
。我的同事正在我们的项目中工作,我们从我的调制解调器路由器共享wifi。我正在尝试将我们的项目置于在线状态,这样他们也可以访问我的项目来查看创建的网站,但我的朋友们得到了这个:
403禁止错误消息
这是我的主人档案:
# 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错误。
答案 0 :(得分:0)
这里好几件事
首先从httpd-vhost.conf文件中删除这两个条目。它们只是为帮助人们入门而提供的示例条目。如果你注意到他们指向你不应该实际拥有的文件夹,即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个允许任何使用内部网络的人访问该网站。