我正在尝试在openSUSE中为一个名为abc.com的站点设置Apache虚拟主机(仅用于示例目的)。 当我在浏览器上访问http://localhost/mysites/abc.com/index.html时,它会正确打开。 但是,当我访问http://abc.com ,它不会打开位于/files/htdocs/mysites/abc.com/index.html上的index.html文件。 相反,它打开了电视networking的网站。
这是我的configuration:
default-server.conf :
DocumentRoot "/files/htdocs" <Directory "/files/htdocs"> Options None AllowOverride All Order allow,deny Allow from all </Directory> NameVirtualHost 127.0.0.1
注意:我没有更改其他默认值。
vhost.conf vhosts.d/ httdp.conf包含在httdp.conf :
<VirtualHost 127.0.0.1> DocumentRoot /files/htdocs/mysites/abc.com servername abc.com </VirtualHost>
有任何想法吗?
您需要将abc.comparsing为您的Web服务器正在侦听的IP地址。 您似乎拥有回送地址127.0.0.1上的所有内容。 最简单的方法是将abc.com添加到定义localhost的/etc/hosts文件的行中。
127.0.0.1 localhost abc.com
你说
但是,当我访问http://abc.com时 ,它不会打开位于/files/htdocs/mysites/abc.com/index.html上的index.htmlHTML文件。 相反,它打开了电视networking的网站。
如果你真的使用abc.com那么这不会是一件好事。 使用abc.lan或abc.local或类似的,你会好得多。
将abc.com域添加到/etc/hosts文件中:
127.0.0.1 localhost.localdomain abc.com