3

我正在尝试使用 apache 为 javascript Web 应用程序设置开发环境,但我似乎无法做最简单的事情,比如设置虚拟主机来提供静态 html、js 和其他文件类型.

这是我在 httpd-vhosts.conf 中尝试做的事情:

<VirtualHost *:80>
    ServerAdmin test@localhost
    ServerName www.nonlocal-blight.com
    ServerAlias www.local-blight.com

    DocumentRoot "/Apache24/documents/WebContent"
    <Directory "WebContent">
        Options Indexes FollowSymLinks
        AllowOverride None
        Order allow,deny
        Allow from all
    </Directory>

</VirtualHost>

index.html在 WebContent 中有一个文件,但无论我尝试访问 www.local-blight.com 还是 www.local-blight.com/index.html,我总是得到“糟糕!谷歌浏览器找不到 [whatever ]”。我尝试删除 ServerAlias、Document 根目录的不同文件夹、删除行Options Indexes FollowSymLinks和所有内容。

我尝试使用httpd.exe -S来检查我的虚拟主机配置,但据我所知,输出看起来不错:

C:\Apache24\bin>httpd.exe -S
VirtualHost configuration:
*:80                   is a NameVirtualHost
         default server www.nonlocal-blight.com (C:/Apache24/conf/extra/httpd-vh
osts.conf:37)
         port 80 namevhost www.nonlocal-blight.com (C:/Apache24/conf/extra/httpd
-vhosts.conf:37)
                 alias www.local-blight.com
         port 80 namevhost www.nonlocal-blight.com (C:/Apache24/conf/extra/httpd
-vhosts.conf:37)
                 alias www.local-blight.com
*:443                  is a NameVirtualHost
         default server localhost (C:/Apache24/conf/extra/httpd-sni.conf:134)
         port 443 namevhost localhost (C:/Apache24/conf/extra/httpd-sni.conf:134
)
         port 443 namevhost localhost (C:/Apache24/conf/extra/httpd-sni.conf:134
)
         port 443 namevhost serverone.tld (C:/Apache24/conf/extra/httpd-sni.conf
:151)
         port 443 namevhost serverone.tld (C:/Apache24/conf/extra/httpd-sni.conf
:151)
         port 443 namevhost servertwo.tld (C:/Apache24/conf/extra/httpd-sni.conf
:166)
         port 443 namevhost servertwo.tld (C:/Apache24/conf/extra/httpd-sni.conf
:166)
ServerRoot: "C:/Apache24"
Main DocumentRoot: "C:/Apache24/documents"
Main ErrorLog: "C:/Apache24/logs/error.log"
Mutex ssl-stapling: using_defaults
Mutex proxy: using_defaults
Mutex ssl-cache: u

sing_defaults
Mutex default: dir="C:/Apache24/logs/" mechanism=default
PidFile: "C:/Apache24/logs/httpd.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
Define: SRVROOT=/Apache24

谁能告诉我我在这里做错了什么?

4

1 回答 1

2

我需要添加以下行:

127.0.0.1 www.local-blight.com

到我的 Windows 主机文件中%SystemRoot%\system32\drivers\etc\hosts

我还需要遵循这个答案以允许我的系统通过浏览器访问文件。

于 2013-08-20T14:12:42.603 回答