简体   繁体   English

虚拟主机:LAN访问,WAMP,Windows 7,Apache 2.4.4,Php 5.4.16; 返回没有权限访问此服务器

[英]Virtual Host: LAN access, WAMP, Windows 7, Apache 2.4.4, Php 5.4.16; returns dont-have-permission-to-access-on-this-server

Before I start.. Good day to all! 在我开始之前..大家好! :) :)

I have problem with my WAMP virtual host.. the other computer on our LAN keeps receiving error forbidden-you-dont-have-permission-to-access-on-this-server.. 我的WAMP虚拟主机有问题..我们局域网上的另一台计算机不断收到错误消息,禁止您不要对此服务器进行访问。

Below is the current settings I have: 以下是我的当前设置:

/httpd.conf /httpd.conf

#
# Deny access to the entirety of your server's filesystem. You must
# explicitly permit access to web content directories in other 
# <Directory> blocks below.
#
<Directory />
    Options FollowSymLinks Includes
    AllowOverride All
    Order allow,deny
    Allow from all
    Require all granted
</Directory>

#
# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
#
DocumentRoot "c:/wamp/www"
<Directory "c:/wamp/www">
    Options Indexes FollowSymLinks
    AllowOverride All
    Order Deny,Allow
    Allow from all
    Allow from 127.0.0.1
    Allow from ::1
    Allow from localhost
</Directory>

/phpmyadmin.conf Alias /phpmyadmin "c:/wamp/apps/phpmyadmin4.0.4/" /phpmyadmin.conf别名/ phpmyadmin“ c:/wamp/apps/phpmyadmin4.0.4/”

# to give access to phpmyadmin from outside 
# replace the lines
#
#      Order Deny,Allow
#   Deny from all
#   Allow from 127.0.0.1
#
# by
#
#        Order Allow,Deny 
#   Allow from all
#

<Directory "c:/wamp/apps/phpmyadmin4.0.4/">
    Options Indexes FollowSymLinks ExecCGI
    AllowOverride all
    Order Deny,Allow
    Allow from all
    Allow from 127.0.0.1
    Allow from ::1
    Allow from localhost
</Directory>

/httpd.vhosts.conf /httpd.vhosts.conf

Listen 127.0.0.1:80

<VirtualHost 127.0.0.1:80>
    ServerName www.ecommerce.local
    ServerAlias ecommerce.local
    DocumentRoot C:/wamp/www/ecommerce
    ErrorLog "C:/wamp/www/ecommerce/logs/error.log"
    CustomLog "C:/wamp/www/ecommerce/logs/access.log" common
    <Directory />
        Require all granted
        Options Indexes FollowSymLinks Includes ExecCGI
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

<VirtualHost 127.0.0.1:80>
    ServerName localhost
    DocumentRoot C:/wamp/www/
</VirtualHost>

Also... 也...

  • tried to ping from other computer response is success 试图从其他计算机ping通成功
  • tried to turn off firewall for both computer 试图关闭两台计算机的防火墙
  • tried to add everyone in www's folder properties 试图将所有人都添加到www的文件夹属性中 changed_to_everyone

I have tried other solutions I found but still to no avail.. I can access " http://ecommerce.local " but the other computer on our LAN recieves forbidden-you-dont-have-permission-to-access-on-this-server error.. 我尝试了其他找到的解决方案,但仍然无济于事。.我可以访问“ http://ecommerce.local ”,但我们局域网上的另一台计算机却禁止访问-此服务器错误..

does it have something to do with our network settings? 与我们的网络设置有关吗? the other computer is also in the same settings... my ip: 192.168.1.198 and the other computer is 192.168.1.192 另一台计算机也具有相同的设置...我的IP:192.168.1.198,另一台计算机是192.168.1.192 ipv4和ipv6设置

Access to Apache has nothing to do with windows access rights on a Windows system. 对Apache的访问与Windows系统上的Windows访问权限无关。 Its all to do with what you tell Apache to allow in. 这与您告诉Apache允许的内容有关。

Also you are using a mixture of Apache 2.2 and Apache 2.4 syntax in most of your access declarations. 另外,大多数访问权限声明中都混合使用了Apache 2.2和Apache 2.4语法。

Apache 2.2
Allow .....

Apache 2.4
Require .....
Require local - means 127.0.0.1 and localhost and ::1
Require ip    - specifies a single ip (192.168.0.10) or a range of ip's (192.168.0)

Apache does not seem to complain yet, but its probably best to stick to the Apache 2.4 syntax. Apache似乎还没有抱怨,但它最好还是坚持使用Apache 2.4语法。

This first change you made is very dangerous and should be changed to this unless you really wanted to give unlimited access to the servers C:\\ drive to anyone that hacks your Apache server. 您所做的第一个更改非常危险,应该更改为该更改,除非您确实确实希望向黑客您的Apache服务器的任何人提供对服务器C:\\驱动器的无限制访问。

#
# Deny access to the entirety of your server's filesystem. You must
# explicitly permit access to web content directories in other 
# <Directory> blocks below.
#
<Directory />
    Options FollowSymLinks Includes
    AllowOverride All
    Require all denied

</Directory>

Again here use Apache 2.4 syntax and be specific about who you want to allow in. 再次在这里使用Apache 2.4语法,并具体说明您想允许的人。

#
# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
#
DocumentRoot "c:/wamp/www"
<Directory "c:/wamp/www">
    Options Indexes FollowSymLinks
    AllowOverride All

    Require local
    Require ip 192.168.0

</Directory>

Now to your Virtual Host definitions 现在到您的虚拟主机定义

You dont need this Listen 127.0.0.1:80 你不需要这个Listen 127.0.0.1:80

Put the localhost definition first so it becomes the default domain, so if a random or misspelt domain name is used this will load. 首先放置localhost定义,使其成为默认域,因此,如果使用随机或拼写错误的域名,则将加载它。 If that comes from an internet ip then they will get an error as only ip's from within you network are allowed access. 如果来自互联网IP,那么他们将收到错误消息,因为仅允许您网络内的IP访问。 This isreally for later when you decide to open up your site to a wider audience. 以后,当您决定向更广泛的受众开放您的网站时,这是非常有用的。

Also dont specify 127.0.0.1 on the line, you want it to be listen any incoming ip not just this machine. 也不要在行上指定127.0.0.1,您希望它监听所有传入的IP,而不仅仅是此机器。

<VirtualHost *:80>
    ServerName localhost
    DocumentRoot "C:/wamp/www"
    <Directory "c:/wamp/www">
        Options Indexes FollowSymLinks
        AllowOverride All

        Require local
        ## May not want to let people access the wamp page so leave this off if not.
        Require ip 192.168.0

    </Directory>
</VirtualHost>


<VirtualHost *:80>
    ServerName www.ecommerce.local
    ServerAlias ecommerce.local
    DocumentRoot "C:/wamp/www/ecommerce"

    ## not a good idea to have logs visible under the DocumentRoot folder
    ## should really go in C:\wamp\logs
    ## But I assume you want developers to have easy access during development
    ## ErrorLog "C:/wamp/logs/ecommerce_error.log"
    ## CustomLog "C:/wamp/logs/ecommerce_access.log" common

    ErrorLog "C:/wamp/www/ecommerce/logs/error.log"
    CustomLog "C:/wamp/www/ecommerce/logs/access.log" common

    <Directory />
        Options Indexes FollowSymLinks Includes ExecCGI
        AllowOverride All

        Require local
        Require ip 192.168.0

    </Directory>
</VirtualHost>

Now you may want to allow your local developers access to phpMyAdmin. 现在,您可能希望允许本地开发人员访问phpMyAdmin。 If so you will need to change your C:\\wamp\\alias\\phpmyadmin.conf file as well. 如果是这样,您还需要更改C:\\wamp\\alias\\phpmyadmin.conf文件。

<Directory "c:/wamp/apps/phpmyadmin4.0.4/">
    Options Indexes FollowSymLinks ExecCGI
    AllowOverride all
    Require local
    Require ip 192.168.0
</Directory>

Or you could be more specific here and only allow certain ip's to use phpMyAdmin by using something like this 或者,您可以在这里更具体一些,只允许某些IP通过使用类似这样的东西来使用phpMyAdmin

Require ip 192.168.0.10 192.168.0.11 192.168.0.12

Just as a side note. 只是作为旁注。 I personally like to move my VistualHosts sites completely out of the C:\\wamp\\ folder structure. 我个人喜欢将VistualHosts网站完全移出C:\\wamp\\文件夹结构。 So I would have placed my ecommerce folder somewhere like C:\\websites\\ecommerce\\www\\ . 因此,我会将我的ecommerce文件夹放置在C:\\websites\\ecommerce\\www\\ This keeps any confusion about access rights to a complete minimum and also if I need to upgrade WAMP, my website code is never in any danger when I make a silly typo. 这使有关访问权限的混淆降至最低,而且如果我需要升级WAMP,则我进行愚蠢的打字错误时,我的网站代码永远不会有任何危险。

ADDITIONAL INFO: 附加信息:

Now to be able to access your new site as ecommerce.local or www.ecommerce.local you will have to make a chnage to your HOSTS file. 现在,要能够以ecommerce.localwww.ecommerce.local身份访问新站点,您将必须对HOSTS文件进行修改。

C:\\windows\\system32\\drivers\\etc\\hosts

On the PC running WAMP add this line: 在运行WAMP的PC上添加以下行:

127.0.0.1 ecommerce.local

On the other PC's do this 在另一台PC上执行此操作

192.168.0.10 ecommerce.local

Where 192.168.0.10 is the ip address of the PC running WAMP 其中192.168.0.10是运行WAMP的PC的IP地址

Then reboot the PC's or do these 2 commands from a command window started as Administrator 然后重新启动PC或从as Administrator启动的命令窗口中执行以下2条命令

net stop "DNS Client"

net start "DNS Client"

I have already solved my own issue... I have not shared my folder for anyone to view... so what I did is: 我已经解决了自己的问题...我没有共享我的文件夹供任何人查看...所以我所做的是:

  1. Right Click the project folder 右键单击项目文件夹
  2. On folder options go to sharing tab 在文件夹选项上,转到共享选项卡
  3. Click on advance sharing 点击高级共享
  4. advance sharing option will open then tick share this folder 预先共享选项将打开,然后勾选共享此文件夹
  5. click permissions 点击权限
  6. permissions option will open then choose whom you would like to share your folder 权限选项将打开,然后选择您要共享文件夹的人
  7. I chose everyone then below tick full control (*for trial purposes only; recommended tick only Read) 我选择了下面所有的人,然后勾选了完全控制(*仅用于试用;建议仅用于勾选状态Read)
  8. then click ok for all the opened options 然后为所有打开的选项单击确定

如何共享文件夹

暂无
暂无

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

相关问题 403禁止访问您没有访问此服务器上的/c:/wamp/www/index.php的权限 - 403 Forbidden You dont have permission to access /c:/wamp/www/index.php on this server 局域网上基于apache,DNS,基于访问名称的虚拟主机,而无需在每台计算机的“主机”文件中键入IP和服务器名称 - apache, DNS, access name based virtual host on LAN without typing the IP and server name at the “hosts” file of every computer 通过LAN从Mac上托管的Windows计算机访问Apache服务器 - Access apache server from windows machine hosted on mac over LAN WAMP您无权访问此服务器上的/ - WAMP You don't have permission to access / on this server WAMP-禁止-您无权访问此服务器上的/ - WAMP - Forbidden - You don't have permission to access / on this server android,您无权访问此服务器上的/ WAMP - android you don't have permission to access / on this server WAMP php服务器端错误“禁止您没有访问此页面的权限” - Php server side error “Forbidden You Dont Have Permission to Access this page” Apache 2.2.17 + Wamp + Windows 7 +在配置虚拟主机时给出403 - Apache 2.2.17 + wamp + windows 7 + gives 403 when configure virtual host 无权访问此服务器上的/*******.php - Don't have permission to access /*******.php on this server 如何在64位WAMP 3上修复“您无权访问此服务器上的/index.php。” - How to fix “You don't have permission to access /index.php on this server.” on 64bit WAMP 3
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM