基于IP虚拟机主机
bash
vim /etc/httpd/conf/httpd.conf
添加监听IP
bash
Listen 192.168.0.1:80
Listen 192.168.0.10:80
添加虚拟主机和发布目录
第一台虚拟主机
bash
<VirtualHost 192.168.0.1:80>
ServerAdmin www.123.com
DocumentRoot /webroot/192.168.0.1
ErrorLog logs/192.168.0.1-error_log
CustomLog logs/192.168.0.1-access_log common
</VirtualHost>
<Directory "/webroot/192.168.0.1" >
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from ALL
</Directory>
第二台虚拟主机
bash
<VirtualHost 192.168.0.10:80>
ServerAdmin www.321.com
DocumentRoot /webroot/192.168.0.10
ErrorLog logs/192.168.0.10-error_log
CustomLog logs/192.168.0.10-access_log common
</VirtualHost>
<Directory "/webroot/192.168.0.10" >
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from ALL
</Directory>
基于端口虚拟主机
bash
vim /etc/httpd/conf/httpd.conf
添加端口
bash
Listen 80
Listen 8080
添加虚拟主机和发布目录
第一台虚拟主机
bash
<VirtualHost *:80>
...配置省略
</VirtualHost>
<Directory "/webroot/xx" >
...配置省略
</Directory>
第一台虚拟主机
bash
<VirtualHost *:8080>
...配置省略
</VirtualHost>
<Directory "/webroot/xx" >
...配置省略
</Directory>