Hun*_*law 0 php wamp windows-7 apache2.4
在我开始之前......祝大家好!:)
我的WAMP虚拟主机有问题..我们局域网上的另一台计算机一直收到错误 - 禁止 - 你没有权限访问此服务器..
以下是我目前的设置:
/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>
Run Code Online (Sandbox Code Playgroud)
/phpmyadmin.conf Alias/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>
Run Code Online (Sandbox Code Playgroud)
/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>
Run Code Online (Sandbox Code Playgroud)
也...

我尝试了其他解决方案,但仍然无济于事.我可以访问" http://ecommerce.local ",但我们局域网上的另一台计算机接收禁止 - 你没有权限访问 -这个服务器错误..
它与我们的网络设置有关吗?另一台计算机也在相同的设置...我的IP:192.168.1.198和另一台计算机是192.168.1.192

访问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)
Run Code Online (Sandbox Code Playgroud)
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>
Run Code Online (Sandbox Code Playgroud)
这里再次使用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>
Run Code Online (Sandbox Code Playgroud)
现在到您的虚拟主机定义
你不需要这个 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>
Run Code Online (Sandbox Code Playgroud)
现在您可能希望允许本地开发人员访问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>
Run Code Online (Sandbox Code Playgroud)
或者你可以在这里更具体,只允许某些ip使用phpMyAdmin使用这样的东西
Require ip 192.168.0.10 192.168.0.11 192.168.0.12
Run Code Online (Sandbox Code Playgroud)
就像旁注一样.我个人喜欢将我的VistualHosts网站完全移出C:\wamp\文件夹结构.所以我会把我的ecommerce文件夹放在某个地方C:\websites\ecommerce\www\.这使得对访问权限的任何混淆达到了最低限度,而且如果我需要升级WAMP,当我制作一个愚蠢的拼写错误时,我的网站代码永远不会有任何危险.
现在能够访问您的新网站,ecommerce.local或者www.ecommerce.local您必须为您的HOSTS文件制作一个chnage.
C:\windows\system32\drivers\etc\hosts
在运行WAMP的PC上添加以下行:
127.0.0.1 ecommerce.local
Run Code Online (Sandbox Code Playgroud)
在另一台PC上这样做
192.168.0.10 ecommerce.local
Run Code Online (Sandbox Code Playgroud)
其中192.168.0.10是运行WAMP的PC的IP地址
然后重启PC或从命令窗口启动这两个命令 as Administrator
net stop "DNS Client"
net start "DNS Client"
Run Code Online (Sandbox Code Playgroud)