[英]Virtual Host setting not working
我在vps服务器上托管两个域。 假设www.abc.net(或abc.net)和www.xyz.net(或xyz.net)的域具有以下配置
<VirtualHost *:80>
ServerName abc.net
ServerAlias www.abc.net
ServerAdmin webmaster@localhost
DocumentRoot /var/www/abc.net
ErrorLog ${APACHE_LOG_DIR}/abc.net.error.log
CustomLog ${APACHE_LOG_DIR}/abc.net.access.log combined
</VirtualHost>
和
<VirtualHost *:80>
ServerName xyz.net
ServerAlias www.xyz.net
ServerAdmin webmaster@localhost
DocumentRoot /var/www/xyz.net
ErrorLog ${APACHE_LOG_DIR}/xyz.net.error.log
CustomLog ${APACHE_LOG_DIR}/xyz.net.access.log combined
</VirtualHost>
除了这些,我还有默认的apache2 00-default-site.conf (不变)和rutorrent.conf
<VirtualHost *:80>
ServerAlias *
DocumentRoot /var/www/
CustomLog /var/log/apache2/rutorrent.log vhost_combined
ErrorLog /var/log/apache2/rutorrent_error.log
SCGIMount /rutorrent/RPC2 127.0.0.1:5000
<Directory "/var/www/rutorrent">
AuthName "user1"
AuthType Basic
Require valid-user
AuthUserFile /var/www/rutorrent/.htpasswd
</Directory>
</VirtualHost>
假设我的IP为tuvw,我有以下/ etc / hosts文件集
127.0.0.1 localhost
127.0.1.1 template.pcsmarthosting.co.uk template
t.u.v.w abc.net
t.u.v.w xyz.net
# The following lines are desirable for IPv6 capable hosts
::1 localhost ip6-localhost ip6-loopback
我可以正确访问www.abc.net,因为它转到正确的文件夹,但是www.xyz.net转到/ var / www /,与http:// tuvw相同
www.xyz.net即使是唯一启用的站点也无法使用。
我该如何解决?
系统主机名可能是www.xyz.net,这意味着000-default的行为就好像隐含了“ ServerName www.xyz.net”一样。
您应该将虚拟ServerName设置为000默认值,这样就没有风险了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.