【问题标题】:Multiple Virtual Sites with Wampserver使用 Wampserver 的多个虚拟站点
【发布时间】:2012-09-12 15:38:27
【问题描述】:

我在创建多个虚拟主机时遇到问题,我已将 C:\wamp\alias\web.local 编辑为如下所示:

NameVirtualHost *:80
<VirtualHost *:80>
    ServerAdmin webmaster@website1.local           
    DocumentRoot "C:/Documents and Settings/username/workspace/www.website1.com"
    ServerName website1.local

    <Directory "C:/Documents and Settings/username/workspace/www.website1.com">
            DirectoryIndex index.php index.htm index.html
            Options Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
            AllowOverride All
            Order allow,deny
            Allow from all
    </Directory>
</VirtualHost>

NameVirtualHost *:80
<VirtualHost *:80>
    ServerAdmin webmaster@website2.local           
    DocumentRoot "C:/Documents and Settings/username/workspace/www.website2.com"
    ServerName website2.local

    <Directory "C:/Documents and Settings/username/workspace/www.website2.com">
            DirectoryIndex index.php index.htm index.html
            Options Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
            AllowOverride All
            Order allow,deny
            Allow from all
    </Directory>
</VirtualHost>

NameVirtualHost *:80
<VirtualHost *:80>
    ServerAdmin webmaster@website3.local           
    DocumentRoot "C:/Documents and Settings/username/workspace/www.website3.com"
    ServerName website3.local

    <Directory "C:/Documents and Settings/username/workspace/www.website3.com">
            DirectoryIndex index.php index.htm index.html
            Options Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
            AllowOverride All
            Order allow,deny
            Allow from all
    </Directory>
</VirtualHost>

NameVirtualHost *:80
<VirtualHost *:80>
    ServerAdmin webmaster@website4.local           
    DocumentRoot "C:/Documents and Settings/username/workspace/www.website4.com"
    ServerName website4.local

    <Directory "C:/Documents and Settings/username/workspace/www.website4.com">
            DirectoryIndex index.php index.htm index.html
            Options Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
            AllowOverride All
            Order allow,deny
            Allow from all
    </Directory>
</VirtualHost>

我的主机文件如下所示:

127.0.0.1       localhost
127.0.0.1       website1.local
127.0.0.1       website2.local
127.0.0.1       website3.local
127.0.0.1       website4.local

我已重新启动 Wampserver,但似乎无法访问 website1.local、website2.local、website3.local 或 website4.local。我收到“网络错误 (dns_unresolved_hostname)”错误消息。

请注意 localhost 是唯一一个似乎可以工作的。

任何帮助表示赞赏。

问候, 斯蒂芬

编辑

我在 Windows XP 上运行 Wampserver 2.2。

【问题讨论】:

  • 从命令提示符运行httpd -t 会发生什么?
  • @LeonardChalis 我收到以下错误:“httpd”不是内部或外部命令、可运行程序或批处理文件。
  • 在命令提示符中首先转到 c:\wamp\bin\apache\apache2.x.x\bin 文件夹(其中 2.x.x 是您的版本),因为 httd 不在您的包含路径中。或者设置你的 PATH 变量:computerhope.com/issues/ch000549.htm 然后再试一次
  • 好的,我收到以下警告 3 次:[warn] NameVirtualHost *:80 has no VirtualHosts
  • 尝试取出 NameVirtualHost *:80 并将其放入主 httpd.conf(可从 wampmanager 菜单访问),然后再次运行 httpd -t。

标签: virtualhost wampserver


【解决方案1】:

几个问题,你不能通过编辑那个文件来创建虚拟主机。

你使用这个文件 c:\wamp\bin\apache\apache.2.x.y\conf\extra\httpd-vhosts.conf 然后您从 https.conf 文件中取消注释“包含 conf/extra/chris-vhosts.conf”,它位于文件底部附近。

现在您在上面引用的 VHOST 定义看起来很不错,因此您可能只需移动到正确的位置即可。

除了

使用包含空格的目录结构是一个非常非常糟糕的主意,例如

DocumentRoot "C:/Documents and Settings/username/workspace/www.website3.com"

将您的网站代码放在这样的结构中会更安全

C:\websites\www\website3
C:\websites\www\website4

甚至

D:\websites\www\website4

还有一件事,你只需要一个参考

NameVirtualHost *:80

通常是 vhost 定义文件的第一行。

【讨论】:

    猜你喜欢
    • 2023-03-28
    • 1970-01-01
    • 2018-05-08
    • 2011-07-30
    • 2011-11-03
    • 2020-11-18
    • 1970-01-01
    • 1970-01-01
    • 2018-08-23
    相关资源
    最近更新 更多