为什么我的基于命名的虚拟主机无法工作?

发布于 2024-12-21 21:40:02 字数 1351 浏览 2 评论 0原文

我的虚拟主机配置如下所示:

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,
from
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
to
127.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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

诺曦 2024-12-28 21:40:02

您必须将域的 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 is www.theag.com). Talk to the folks who manage your nameservers.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文