0

在我开始之前.. 祝大家有美好的一天!:)

我的 WAMP 虚拟主机有问题.. 我们 LAN 上的另一台计算机不断收到错误消息,禁止您没有权限访问此服务器..

以下是我当前的设置:

/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 别名 /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

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>

还...

  • 尝试从其他计算机 ping 响应成功
  • 试图关闭两台计算机的防火墙
  • 试图在 www 的文件夹属性中添加所有人 更改为所有人

我已经尝试过我找到的其他解决方案,但仍然无济于事。我可以访问“ http://ecommerce.local ”,但我们局域网上的另一台计算机收到了禁止的-you-dont-have-permission-to-access-on-此服务器错误..

它与我们的网络设置有关吗?另一台电脑也是同样的设置……我的ip:192.168.1.198,另一台电脑是192.168.1.192 ipv4 和 ipv6 设置

4

2 回答 2

5

访问 Apache 与 Windows 系统上的 Windows 访问权限无关。这与您告诉 Apache 允许的内容有关。

此外,您在大多数访问声明中混合使用了 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 似乎还没有抱怨,但最好还是坚持使用 Apache 2.4 语法。

您所做的第一个更改非常危险,除非您真的想将服务器 C:\ 驱动器的访问权限授予任何入侵您的 Apache 服务器的人,否则应该更改为这个。

#
# 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>

这里再次使用 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>

现在到您的虚拟主机定义

你不需要这个 Listen 127.0.0.1:80

localhost定义放在首位,使其成为默认域,因此如果使用随机或拼写错误的域名,则会加载。如果这来自互联网 IP,那么他们将收到错误消息,因为仅允许您网络内的 IP 访问。当您决定向更广泛的受众开放您的网站时,这确实是为了以后。

也不要在线上指定 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>

现在您可能希望允许本地开发人员访问 phpMyAdmin。如果是这样,您还需要更改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>

或者你可以在这里更具体,只允许某些 ip 通过使用类似这样的东西来使用 phpMyAdmin

Require ip 192.168.0.10 192.168.0.11 192.168.0.12

就像旁注一样。我个人喜欢将我的 VistualHosts 站点完全移出C:\wamp\文件夹结构。所以我会把我的ecommerce文件夹放在像C:\websites\ecommerce\www\. 这样可以将访问权限的混淆降至最低,而且如果我需要升级 WAMP,当我犯了一个愚蠢的错字时,我的网站代码永远不会有任何危险。

附加信息:

现在为了能够访问您的新站点,ecommerce.local否则www.ecommerce.local您将不得不对您的 HOSTS 文件进行更改。

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

在运行 WAMP 的 PC 上添加以下行:

127.0.0.1 ecommerce.local

在另一台 PC 上执行此操作

192.168.0.10 ecommerce.local

其中 192.168.0.10 是运行 WAMP 的 PC 的 ip 地址

然后重新启动 PC 或从启动的命令窗口执行这 2 个命令as Administrator

net stop "DNS Client"

net start "DNS Client"
于 2014-04-05T16:26:22.197 回答
0

我已经解决了我自己的问题......我没有共享我的文件夹供任何人查看......所以我所做的是:

  1. 右键单击项目文件夹
  2. 在文件夹选项上,转到共享选项卡
  3. 点击提前分享
  4. 高级共享选项将打开,然后勾选共享此文件夹
  5. 点击权限
  6. 权限选项将打开,然后选择您要共享文件夹的人
  7. 我选择了所有人,然后在下面勾选完全控制(*仅供试用;推荐只勾选阅读)
  8. 然后单击确定所有打开的选项

如何共享文件夹

于 2014-04-05T16:38:48.767 回答