我正在尝试使用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>
我在WebContent中有一个index.html
文件,但无论我是去www.local-blight.com,还是www.local-blight.com/index.html,我总是得到“哎呀!谷歌Chrome无法找到[无论如何]。我已经尝试删除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
谁能告诉我这里我做错了什么?
答案 0 :(得分:2)
我需要添加一行:
127.0.0.1 www.local-blight.com
到%SystemRoot%\system32\drivers\etc\hosts
中的我的Windows主机文件。
我还需要关注this answer以允许我的系统通过浏览器访问文件。