红联Linux门户
Linux帮助

linux服务器上设置多主机头,设置多web站点

发布时间:2016-07-12 10:27:01来源:linux网站作者:bai_yan
假设VPS的IP是58.130.17.168,有两个域名指向该IP,分别是domain1.com, domain2.com,
修改/etc/httpd/conf/httpd.conf,在文件的最后加入:
ServerName 58.130.17.168
NameVirtualHost 58.130.17.168 
<VirtualHost 58.130.17.168>
ServerName domain1.com
DocumentRoot /var/www/domain1.com
<Directory "/var/www/domain1.com">
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost 58.130.17.168>
ServerName domain2.com
DocumentRoot /var/www/domain2.com
<Directory "/var/www/domain2.com">
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
 
然后在/var/www/domain1.com和/var/www/domain2.com下创建不同的index.html文件:
echo "domain1">/var/www/domain1.com/index.html
echo "domain2">/var/www/domain2.com/index.html
 
本文永久更新地址:http://www.linuxdiyf.com/linux/22299.html