2013-08-20 53 views
3

我想设置一个使用Apache的JavaScript Web应用程序的开发环境,但我似乎无法做到最简单的事情,比如设置虚拟主机为静态html,js和其他文件类型提供服务。设置Apache虚拟主机来提供静态文件

这里就是我想在的httpd-vhosts.conf做:

<VirtualHost *:80> 
    ServerAdmin [email protected] 
    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,我总是会得到“糟糕!谷歌浏览器无法找到[无论]”。我尝试删除ServerAlias文档根目录的不同文件夹,删除了行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 

谁能告诉我,我做错了什么吗?

+1

总是要开始的第一点是http服务器日志文件。检查“访问”日志文件中对服务器实际做出的请求,并比较“错误”日志文件中报告的错误。 – arkascha

+0

两者都没有。当我尝试去www.local-blight.com时,我没有访问日志,也没有错误日志。 – CorayThan

+1

所以显然这些请求并没有针对你的http服务器。听起来像名称解析问题。或者可能是您阻止了防火墙的请求?通过向http服务器发送telnet请求进行测试:'telnet www.nonlocal-blight.com http'。它被拒绝还是连接? – arkascha

回答

2

我需要添加一行:

127.0.0.1 www.local-blight.com 

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

我还需要关注this answer以允许我的系统通过浏览器访问文件。