[英]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... 也...
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
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,则我进行愚蠢的打字错误时,我的网站代码永远不会有任何危险。
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.local
或www.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: 我已经解决了自己的问题...我没有共享我的文件夹供任何人查看...所以我所做的是:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.