无法使用apache vHosts连接到本地计算机上的VirtualDocumentRoot
我有点卡住了。我没有准备好我的本地机器进行开发,因为我的vHost配置无法正常工作。由于浏览器连接失败,我无法访问我的文档根目录。可以连接到服务器 详情:无法使用apache vHosts连接到本地计算机上的VirtualDocumentRoot,apache,configuration,port,vhosts,Apache,Configuration,Port,Vhosts,我有点卡住了。我没有准备好我的本地机器进行开发,因为我的vHost配置无法正常工作。由于浏览器连接失败,我无法访问我的文档根目录。可以连接到服务器 详情: OS: OSX 10.9.2 Apache/2.2.26 vHost配置如下所示: <VirtualHost *:80> ServerAdmin me@something.com ServerName something.loc ServerAlias *.someting.loc UseCanonicalNam
OS: OSX 10.9.2
Apache/2.2.26
vHost配置如下所示:
<VirtualHost *:80>
ServerAdmin me@something.com
ServerName something.loc
ServerAlias *.someting.loc
UseCanonicalName Off
VirtualDocumentRoot /path/to/vhosts/%2/%1/htdocs
<IfModule dir_module>
DirectoryIndex index.php index.html
</IfModule>
<FilesMatch "\.js\.gzip$">
AddType "text/javascript" .js.gzip
</FilesMatch>
<FilesMatch "\.css\.gzip$">
AddType "text/css" .css.gzip
</FilesMatch>
AddEncoding x-gzip .gzip
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/plain text/html
</IfModule>
</virtualHost>
mod_vhost_alias apache模块已加载:
LoadModule vhost_alias_module libexec/apache2/mod_vhost_alias.so
因此,我无法通过浏览器访问index.html,但在尝试时在apache error.log中没有任何内容。因此,让我们尝试使用wget:
$ wget dev.test.something.loc
--2014-04-05 10:12:40-- http://dev.test.something.loc/
Resolving dev.test.something.loc... 127.0.0.1
Connecting to dev.test.something.loc|127.0.0.1|:80... failed: Connection refused.
好的,不行。下一个办法:
wget --header="Host: dev.test.something.loc" -O - http://localhost
--2014-04-05 10:14:53-- http://localhost/
Resolving localhost... ::1, 127.0.0.1
Connecting to localhost|::1|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 67 [text/html]
Saving to: 'STDOUT'
0% [ ] 0 --.-K/s <html>
<head>
</head>
<body>
<h1>Hello World!</h1>
</body>
</html>
100%[============================>] 67 --.-K/s in 0s
2014-04-05 10:14:53 (5.32 MB/s) - written to stdout [67/67]
到目前为止我只知道这些。显然有点不对劲。但我对整个apache配置还不够熟悉,我无法自己找出我缺少的东西。也许有人能提供一些有用的建议
提前感谢。我仍然不知道问题出在哪里,但是格式化SSD并从头开始使用新的OS X就可以解决问题。同样的配置工作起来很有魅力。结束问题
wget --header="Host: dev.test.something.loc" -O - http://localhost
--2014-04-05 10:14:53-- http://localhost/
Resolving localhost... ::1, 127.0.0.1
Connecting to localhost|::1|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 67 [text/html]
Saving to: 'STDOUT'
0% [ ] 0 --.-K/s <html>
<head>
</head>
<body>
<h1>Hello World!</h1>
</body>
</html>
100%[============================>] 67 --.-K/s in 0s
2014-04-05 10:14:53 (5.32 MB/s) - written to stdout [67/67]
wget --header="Host: dev.test.something.loc" -O - 127.0.0.1
--2014-04-05 10:17:24-- http://127.0.01/
Resolving 127.0.0.1... 127.0.0.1
Connecting to 127.0.0.1|127.0.0.1|:80... failed: Connection refused.