# vim /etc/hosts
一.搭建基于域名虚拟主机需修改
www.linuxidc.com 192.168.100.10
www.linuxmi.com 192.168.100.10
二.搭建基于IP的虚拟主机
1.修改主配置文件
# ifconfig eth0:0 192.168.100.20 //设置另一个IP
# vi /etc/httpd/conf/httpd.conf
#NameVirtualHost *:80 //不需要这行
<VirtualHost 192.168.10.10:80>
DocumentRoot /data/web/linuxidc
ServerName 192.168.100.10
ErrorLog logs/192.168.100.10-error_log
CustomLog logs/192.168.100.10-access_log common
</VirtualHost>
<VirtualHost 192.168.100.20:80>
DocumentRoot /data/web/linuxmi
ServerName 192.168.100.20
ErrorLog logs/192.168.100.20-error_log
CustomLog logs/192.168.100.20-access_log common
</VirtualHost>
2.启动服务
# service httpd restart
# chkconfig httpd on
3.浏览器测试
http://192.168.100.10
http://192.168.100.20