为什么我的基于命名的虚拟主机无法工作?
我的虚拟主机配置如下所示:
Listen 80
...
DocumentRoot "/www/mysite"
...
<Directory "/www/mysite">
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
...
<Files ~ "^\.ht">
Order allow,deny
Deny from all
</Files>
...
NameVirtualHost *:80
...
<VirtualHost *:80>
ServerAdmin [email protected]
ServerName theag.com
ServerAlias www.theag.com
DocumentRoot "/www/mysite"
ErrorLog logs/dummy-host.example.com-error_log
CustomLog logs/dummy-host.example.com-access_log common
</VirtualHost>
虽然本地主机可以工作,但当我尝试连接到 ServerName theag.com 时,如 VirtualHost 部分所述,我得到一个 theag.com >找不到服务器。 我做错了什么?或者我应该做什么才能让它正常工作?
ps ...
表示之间的配置行。
解决方法:出于测试目的,这就是我所做的:
我刚刚编辑了 /etc/hosts, 来自127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
到127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 theag.com www.theag.com
。
这将使它发挥作用。您现在将使用 127.0.0.1 作为 IP 地址。
My virtual host configuration looks like this:
Listen 80
...
DocumentRoot "/www/mysite"
...
<Directory "/www/mysite">
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
...
<Files ~ "^\.ht">
Order allow,deny
Deny from all
</Files>
...
NameVirtualHost *:80
...
<VirtualHost *:80>
ServerAdmin [email protected]
ServerName theag.com
ServerAlias www.theag.com
DocumentRoot "/www/mysite"
ErrorLog logs/dummy-host.example.com-error_log
CustomLog logs/dummy-host.example.com-access_log common
</VirtualHost>
Although the localhost works, when I try to connect to the ServerName theag.com as described in the VirtualHost section, I get a Server not found.
What am i doing wrong? or What am I supposed to do to get it it working?
p.s. ...
signifies the configuration lines in between.
Workaround : For testing purposes this is what I have done:
I just edited the /etc/hosts,
from127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
to127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 theag.com
.
www.theag.com
This will get it to work. You will be using the 127.0.0.1 as the ip-address for now.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您必须将域的 DNS 安排为指向您服务器的 IP 地址。如果
theag.com
是实际名称,则它当前不与任何 IP 地址关联(www.theag.com
也不关联)。与管理您的域名服务器的人员交谈。You have to arrange the domain's DNS to point to your server's IP address. If
theag.com
is the actual name, it's currently not associated with any IP address (neither iswww.theag.com
). Talk to the folks who manage your nameservers.