我为 wamp 创建了一个多站点,这在服务器 pc 上运行良好,但不确定如何从网络访问这些站点。我将所有站点的文件夹放在 wamp 的根目录中,即“www”之前的文件夹。
这是apache conf的一部分
#virtual sites
NameVirtualHost *:80
<VirtualHost 127.0.0.1>
ServerName localhost
DocumentRoot "C:/wamp/www"
</VirtualHost>
<VirtualHost 127.0.0.1>
ServerName client1.localhost
DocumentRoot "C:/wamp/client1"
<Directory "C:/wamp/client1">
allow from all
order allow,deny
AllowOverride All
Require all granted
</Directory>
DirectoryIndex index.html index.php
</VirtualHost>
<VirtualHost 127.0.0.1>
ServerName client2.localhost
DocumentRoot "C:/wamp/client2"
<Directory "C:/wamp/client2">
allow from all
order allow,deny
AllowOverride All
Require all granted
</Directory>
DirectoryIndex index.html index.php
</VirtualHost>
这是主机条目
127.0.0.1 localhost
127.0.0.1 client1.localhost
127.0.0.1 client2.localhost
127.0.0.1 client3.localhost
通过转到 x.localhost(x = 客户端文件夹),这在服务器的 pc 浏览器中可以正常工作。我将客户端 PC 上的主机文件更改为:
127.0.0.1 localhost
192.168.0.100 main
192.168.0.100 client1.main
192.168.0.100 client2.main
192.168.0.100 client3.main
在客户端的浏览器上,这些 url 都显示了主 wampserver index.php,而不是其分配的文件夹/站点。