帮助在Windows Vista中设置具有Wamp的虚拟主机

时间:2014-04-02 23:40:46

标签: wamp virtual host

我需要一些帮助来设置这个东西。

我遵循了有关在WAMP中设置虚拟主机的教程,其中包括以下步骤:

  1. 在文件夹httpd.conf中打开文件C:\wamp\bin\apache\apache2.2.6\conf并取消注释以下语句的最后一个#:

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

    看起来像这样:

    # Virtual hosts
    Include conf/extra/httpd-vhosts.conf
    
  2. 打开文件夹httpd-vhosts.conf中的文件C:\wamp\bin\apache\apache2.2.6\conf\extra,删除了其中的所有内容,并替换为以下代码:

    NameVirtualHost *:80
    
    <VirtualHost *:80>
    ServerName www.jagerseow.servegame.com (WHICH IS A DOMAIN A REGISTERED IN NO-IP)
    ServerAlias jagerseow.servegame.com domain
    DocumentRoot C:/wamp/www/MP4Public
    ErrorLog "C:/wamp/www/MP4Public/logs/error.log"
    CustomLog "C:/wamp/www/MP4Public/logs/access.log" common
    </VirtualHost>"
    
    <VirtualHost *:80>
    ServerName localhost
    DocumentRoot C:/wamp/www
    ErrorLog "C:/wamp/www/logs/error.log"
    CustomLog "C:/wamp/www/logs/access.log" common
    </VirtualHost>
    
  3. 使用记事本在服务器计算机上的文件夹hosts中打开文件C:/Windows/System32/drivers/etc;然后,使用以下代码删除并替换默认代码:

    127.0.0.1 localhost
    127.0.0.1 domain
    
  4. 重新启动WAMP并等到它变为绿色,它确实......

  5. 尝试通过在浏览器中键入域来连接到我的服务器页面,并且我的网页正常显示。但是,当任何人(包括我自己)尝试通过键入地址(http://www.jagerseow.servegame.com)来打开它时,不会加载任何页面。
  6. 我正在运行Windows Vista 32位。任何人都可以告诉我我做错了什么?

1 个答案:

答案 0 :(得分:0)

将虚拟主机定义更改为: -

NameVirtualHost *:80

## must be first so the the wamp menu page loads
## and stray hacks get sent here and ignored because access 
## is only allowed from local ips (127.0.0.1 localhost ::1 )
<VirtualHost *:80>
    DocumentRoot "C:/wamp/www"
    ServerName localhost
    ServerAlias localhost
    <Directory  "C:/wamp/www">
        Order Deny,Allow
        Deny from all
        Allow from 127.0.0.1 localhost ::1 
    </Directory>
</VirtualHost>


<VirtualHost *:80>
    ServerName www.jagerseow.servegame.com 
    ServerAlias jagerseow.servegame.com
    DocumentRoot "C:/wamp/www/MP4Public"
    # changed, dont want your logs available under your docroot directory (security)
    ErrorLog "C:/wamp/www/logs/MP4Public_error.log"
    CustomLog "C:/wamp/www/logs/MP4Public_access.log" common
    <Directory  "D:/wamp/www/MP4Public">
        Order Allow,Deny
        Allow from all
    </Directory>

</VirtualHost>"

现在您需要将主机文件更改为: -

127.0.0.1 localhost
127.0.0.1 jagerseow.servegame.com

更改后,执行以下操作或重新启动。 运行命令窗口Run as Administrator并执行

net stop "DNS Client"
net start "DNS Client"

这将强制刷新DNS缓存并在您的PC上提供新的域名。

主机文件由Windows加载到其DNS缓存中。它预加载网址,有点像一个非常低功能的DNS。所以这告诉dns缓存,因此告诉您的浏览器等jagerseow.servegame.com在IP地址127.0.0.1上找到this PC

如果您确实希望Universe能够看到此站点,我假设您使用Allow from all,那么您必须将路由器上的端口80转发到PC的IP地址运行wamp。此外,PC将需要一个STATIC IP地址,以便在重新启动时不会更改。可以在此处找到帮助PortForward.com

相关问题