<VirtualHost 192.168.0.1:80>
ServerAdmin root@linuxidc.com
DocumentRoot /www/html/www1.linuxidc.com
ServerName www1.linuxidc.com
ErrorLog logs/www1.linuxidc.com-error_log
CustomLog logs/www1.linuxidc.com-access_log common
</VirtualHost>
<VirtualHost 192.168.0.2:80>
ServerAdmin root@linuxidc.com
DocumentRoot /www/html/www2.linuxidc.com
ServerName www2.linuxidc.com
ErrorLog logs/www2.linuxidc.com-error_log
CustomLog logs/www2.linuxidc.com-access_log common
</VirtualHost>
4.2、基于端口的虚拟主机
<VirtualHost 192.168.0.1:80>
ServerAdmin root@linuxidc.com
DocumentRoot /www/html/www1.linuxidc.com
ServerName www1.linuxidc.com
ErrorLog logs/www1.linuxidc.com-error_log
CustomLog logs/www1.linuxidc.com-access_log common
</VirtualHost>
<VirtualHost 192.168.0.1:8080>
ServerAdmin root@linuxidc.com
DocumentRoot /www/html/www2.linuxidc.com
ServerName www2.linuxidc.com
ErrorLog logs/www2.linuxidc.com-error_log
CustomLog logs/www2.linuxidc.com-access_log common
</VirtualHost>
4.3、基于域名的虚拟主机
1、配置好DNS服务器,使多个域名能解析到同个ip地址上
2、编辑/etc/httpd/conf/httpd.conf
NameVirtualHost 192.168.0.1:80 #启用基于域名的虚拟主机
<VirtualHost 192.168.0.1:80>
ServerAdmin root@linuxidc.com
DocumentRoot /www/html/www1.linuxidc.com
ServerName www1.linuxidc.com
ErrorLog logs/www1.linuxidc.com-error_log
CustomLog logs/www1.linuxidc.com-access_log common
</VirtualHost>
<VirtualHost 192.168.0.1:80>
ServerAdmin root@linuxidc.com
DocumentRoot /www/html/www2.linuxidc.com
ServerName www2.linuxidc.com
ErrorLog logs/www2.linuxidc.com-error_log
CustomLog logs/www2.linuxidc.com-access_log common
</VirtualHost>
Ubuntu Server 14.04 安装Web服务器(Linux+Apache+MySQL+PHP)
Ubuntu 13.04 安装 LAMP\Vsftpd\Webmin\phpMyAdmin 服务及设置
CentOS 5.9下编译安装LAMP(Apache 2.2.44+MySQL 5.6.10+PHP 5.4.12)
RedHat 5.4下Web服务器架构之源码构建LAMP环境及应用PHPWind