【问题标题】:Aid in setting up a Virtual Host with Wamp in Windows Vista帮助在 Windows Vista 中使用 Wamp 设置虚拟主机
【发布时间】:2014-05-14 13:06:45
【问题描述】:

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

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

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

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

    看起来像这样:

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

    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. 使用记事本打开服务器计算机上C:/Windows/System32/drivers/etc文件夹中的文件hosts;然后,删除并用这些代码替换默认代码:

    127.0.0.1 localhost
    127.0.0.1 domain
    
  4. 重新启动 WAMP 并等待它变成绿色,它确实如此...

  5. 尝试通过在浏览器中键入域连接到我的服务器页面,我的网页正常显示。但是,当任何人(包括我自己)尝试通过输入地址 (http://www.jagerseow.servegame.com) 来打开它时,不会加载任何页面。

我正在运行 Windows Vista 32 位。谁能告诉我我做错了什么?

【问题讨论】:

    标签: wamp virtual host


    【解决方案1】:

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

    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 缓存中。它预先加载了 url,有点像一个功能非常低的 DNS。因此,这会告诉 dns 缓存以及您的浏览器等 jagerseow.servegame.com 在 IP 地址 127.0.0.1 上找到,即 this PC

    如果你真的希望宇宙能够看到这个站点,我假设你像使用 Allow from all 那样做,然后你必须将路由器上的端口 80 端口转发到运行 wamp 的 PC 的 IP 地址.此外,该 PC 将需要一个静态 IP 地址,因此在您重新启动时它不会更改。可以在这里找到帮助PortForward.com

    【讨论】:

      猜你喜欢
      • 2013-03-15
      • 2014-07-15
      • 2014-09-20
      • 2015-01-25
      • 1970-01-01
      • 2016-01-23
      • 2014-04-08
      • 2017-02-01
      • 1970-01-01
      相关资源
      最近更新 更多