基于IP虚拟机主机
vim /etc/httpd/conf/httpd.conf
添加监听IP
Listen 192.168.0.1:80
Listen 192.168.0.10:80
添加虚拟主机和发布目录
第一台虚拟主机
<VirtualHost 192.168.0.1:80>ServerAdmin www.123.comDocumentRoot /webroot/192.168.0.1ErrorLog logs/192.168.0.1-error_logCustomLog logs/192.168.0.1-access_log common</VirtualHost><Directory "/webroot/192.168.0.1" >Options Indexes FollowSymLinksAllowOverride NoneOrder allow,denyAllow from ALL
</Directory>
第二台虚拟主机
<VirtualHost 192.168.0.10:80>ServerAdmin www.321.comDocumentRoot /webroot/192.168.0.10ErrorLog logs/192.168.0.10-error_logCustomLog logs/192.168.0.10-access_log common
</VirtualHost><Directory "/webroot/192.168.0.10" >Options Indexes FollowSymLinksAllowOverride NoneOrder allow,denyAllow from ALL
</Directory>
基于端口虚拟主机
vim /etc/httpd/conf/httpd.conf
添加端口
Listen 80
Listen 8080
添加虚拟主机和发布目录
第一台虚拟主机
<VirtualHost *:80>
...配置省略
</VirtualHost><Directory "/webroot/xx" >
...配置省略
</Directory>
第一台虚拟主机
<VirtualHost *:8080>
...配置省略
</VirtualHost><Directory "/webroot/xx" >
...配置省略
</Directory>