而温柔 发表于 2014-4-24 09:00:59

Apache配置多虚拟主机

1. 安装服务
yum -y install httpd
2. 修改主配置文件


# cd /etc/httpd
# vim conf/httpd.conf
ServerName localhost:80
NameVirtualHost *:80 #去掉注释,开启虚拟主机


# vim conf.d/virtual.conf
<VirtualHost *:80>
ServerAdmin zhengyansheng@zqvideo.com
DocumentRoot /var/www1
ServerName www.allentuns1.com
ErrorLog logs/allentuns1-error_log
CustomLog logs/allentuns1-access_log common
</VirtualHost>
<VirtualHost *:80>
ServerAdmin zhengyansheng@zqvideo.com
DocumentRoot /var/www2
ServerName www.allentuns2.com
ErrorLog logs/allentuns2-error_log
CustomLog logs/allentuns2-access_log common
</VirtualHost>
# mkdir /var/www1
# echo "<h1>Hello,Welcome to Allentuns</h1>" > /var/www1/index.html
# service httpd restart
# mkdir /var/www2
# echo "<h1>Hello,Welcome to A+B=C</h1>" > /var/www2/index.html
# service httpd restart
3. 测试

页: [1]
查看完整版本: Apache配置多虚拟主机