简体   繁体   English

WampServer v2.5上线403错误被禁止

[英]WampServer v2.5 Put Online 403 Error Forbidden

I downloaded wampserver to create our php application and I already setup my domain thesis.dev in my host file. 我下载了wampserver来创建我们的php应用程序,并且已经在主机文件中设置了域thesis.dev My groupmates are working in our project and we share wifi from my modem router. 我的队友正在我们的项目中工作,我们从调制解调器路由器共享wifi。 I am trying to Put Online our project so that they can also access my project to view the created website but my friends are getting this: 我正在尝试将我们的项目放到网上,以便他们也可以访问我的项目以查看创建的网站,但是我的朋友正在得到这个:

403 Forbidden Error Message 403禁止错误消息

This is my host file: 这是我的主机文件:

# 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

and this is my httpd-vhosts.conf file: 这是我的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>

My Apache version: 2.4.9. 我的Apache版本:2.4.9。 My MySQL version: 5.6.17. 我的MySQL版本:5.6.17。 My PHP version: 5.5.12 我的PHP版本:5.5.12

My IP address is 192.168.1.2. 我的IP地址是192.168.1.2。

My friends are trying to access 192.168.1.2 on a browser but getting 403 error. 我的朋友正在尝试在浏览器上访问192.168.1.2,但收到403错误。

Ok a few things here 好的,这里有几件事

First remove these 2 entries from the httpd-vhost.conf file. 首先从httpd-vhost.conf文件中删除这2个条目。 They are just example entries provided to help people get started. 它们只是示例条目,旨在帮助人们入门。 If you note they point to folders you should not actually have ie C:/Apache24 etc 如果您注意到它们指向您实际上不应该拥有的文件夹,例如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>

Secondly, when you start to use Virtual Hosts the Put Online and Put Offline become redundant. 其次,当您开始使用虚拟主机时, Put OnlinePut Offline变得多余。 Your Apache security is now held within each VirtualHosts definition. 现在,您的Apache安全性保存在每个VirtualHosts定义中。 So if you want to open your thesis.dev site up to others on your local network ie others sharing your router over wifi you need to tell Apache that thats allowed, so chnage this VH definition like so :- 因此,如果您想向本地网络上的其他人开放您的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>

Note I added this line 注意我添加了这一行

Require ip 192.168.1

as an example, all you need to do is check that your routers DHCP server is giving ip addresses in the subnet 192.168.1 Thats the norm for home routers but yours could be different. 例如,您需要做的就是检查路由器DHCP服务器是否在子网192.168.1中提供了IP地址。这是家用路由器的标准,但您的标准可能有所不同。

Check yours by running this from a command line 通过从命令行运行此命令来检查您的

ipconfig

Then check for this line 然后检查这一行

IPv4 Address. . . . . . . . . . . : 192.168.1.11

And use the first 3 of the 4 quartiles to allow anybody that is using your internal network access to the web site. 并使用4个四分位数中的前3个,允许使用您内部网络的任何人访问该网站。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM