apache 2.2 中的虚拟主机问题
我在虚拟主机配置中遇到奇怪的问题, 这就是当前的情况:
NameVirtualHost *:80
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot /var/www/html/site1.com
ServerName site1.co.il
</VirtualHost>
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot /var/www/html/site2.com
ServerName site2.com
</VirtualHost>
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot /var/www/html/site3.com
ServerName site3.com
</VirtualHost>
如果我改变顺序,一切都会出错! 我不明白为什么顺序很重要! 如果我要添加一个新站点,并将新域引用到我的 IP, 如果我不把它放在第一位,它会引用其他域..
(运行操作系统centos,apache版本:2.2) 有人知道我能做什么吗? 多谢!
i have strange problem in virtual host configurations,
this is what is currentky have:
NameVirtualHost *:80
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot /var/www/html/site1.com
ServerName site1.co.il
</VirtualHost>
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot /var/www/html/site2.com
ServerName site2.com
</VirtualHost>
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot /var/www/html/site3.com
ServerName site3.com
</VirtualHost>
if i'm changing the order, everything goes wrong!
i dont unterstand why the order is important!
if i am adding a new site, and refering new domain to my ip,
if i wont put it first, it will reffer to other domain..
(runs os centos, apache vertion: 2.2)
does someone knows what can i do?
thanks alot!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不确定我是否明白问题所在。所有三个域看起来都将绑定到相同的 IP 地址,因此如果您使用 apache 服务器 IP 地址访问站点,将提供第一个 DocumentRoot。
如果您没有指向这些网站的域,您可以将主机文件设置为 ServerName 或每个部分中定义的任何别名以访问这些特定的 DocumentRoots。
I am not sure I am following what the problem is. All three domains look like they will bind to the same IP address so if you access your sites using the apache server IP address the first DocumentRoot will be served.
If you don't have domains pointed to these websites you could set your hosts file to the ServerName or any alias defined in each section to access those specific DocumentRoots.