在wamp中访问具有IP的本地子域

时间:2013-08-19 06:09:40

标签: subdomain wamp

我需要的是

我能够访问本地计算机中的子域,如下test.localhost但我需要test.myMachineNametest.myMachineIp才能从我自己网络中的另一台计算机访问

我在本地wamp服务器中设置了子域,如下所示:

在https-vhost.conf中:

<VirtualHost *:80>
    #ServerAdmin webmaster@dummy-host.example.com
    DocumentRoot "c:/wamp/www"
    ServerName localhost
    ServerAlias localhost
    #ErrorLog "logs/dummy-host.example.com-error.log"
    #CustomLog "logs/dummy-host.example.com-access.log" common
</VirtualHost>

<VirtualHost *:80>
    #ServerAdmin webmaster@dummy-host.example.com
    DocumentRoot "c:/wamp/www/test"
    ServerName localhost
    ServerAlias test.localhost
    #ErrorLog "logs/dummy-host.example.com-error.log"
    #CustomLog "logs/dummy-host.example.com-access.log" common
</VirtualHost>

然后在httpd.conf中启用vhost

# Virtual hosts
Include conf/extra/httpd-vhosts.conf

然后在Windows主机中添加如下

127.0.0.1       test.localhost

1 个答案:

答案 0 :(得分:1)

我不明白你的配置。首先,如果您从另一台计算机访问test.localhost将无法正常工作,因为该计算机上不存在您的网站。您必须在路由器设置中使用IP地址和端口转发(专用IP:计算机本地IP,类型:TCP,范围:80 - 80)。

https-vhost.conf

<VirtualHost *:80>
    #ServerAdmin webmaster@dummy-host.example.com
    DocumentRoot "c:/wamp/www"
    ServerName localhost
    ServerAlias localhost
    #ErrorLog "logs/dummy-host.example.com-error.log"
    #CustomLog "logs/dummy-host.example.com-access.log" common
</VirtualHost>

<VirtualHost *:80>
    #ServerAdmin webmaster@dummy-host.example.com
    DocumentRoot "c:/wamp/www/test"
    ServerName test.youripaddress
    ServerAlias test.youripaddress
    #ErrorLog "logs/dummy-host.example.com-error.log"
    #CustomLog "logs/dummy-host.example.com-access.log" common
</VirtualHost>

HOST 文件中:

127.0.0.1           localhost
youripaddress       test.youripaddress

问我任何问题。