CentOS7配置Apache多站点VirtualHost

原文链接:http://blog.csdn.net/fly_xiaoba/article/details/49592943

//创建两个网站的目录结构及测试用页面文件

[html]  view plain  copy
  1. # mkdir /www/test1  
  2. # echo "test1" > /www/test1/index.html  
  3. # mkdir /www/test2  
  4. # echo "test2" > /www/test2/index.html  

 //配置虚拟机主机

[html]  view plain  copy
  1. # cd /etc/httpd/  
  2. # mkdir vhost-conf.d  
  3. # echo "Includevhost-conf.d/*.conf" >> conf/httpd.conf  
  4. # vi /etc/httpd/vhost-conf.d/vhost-name.conf  

//添加如下内容

[html]  view plain  copy
  1. <VirtualHost *:80>  
  2.    ServerName example1.com  
  3.    ServerAlias example1.com www.example1.com  
  4.    DocumentRoot /var/www/test1/  
  5.    DirectoryIndex index.html index.php  
  6. </VirtualHost>  
  7. <Directory "/var/www/test1/">  
  8.    Options +Includes -Indexes  
  9.    AllowOverride All  
  10.    Order Deny,Allow  
  11.    Allow from All  
  12. </Directory>  
  13. <VirtualHost *:80>  
  14.    ServerName example2.com  
  15.    ServerAlias example2.com www.example2.com  
  16.    DocumentRoot /var/www/test2/  
  17.    DirectoryIndex index.html index.php  
  18. </VirtualHost>  
  19. <Directory "/var/www/test2/“>  
  20.    Options +Includes -Indexes  
  21.    AllowOverride All  
  22.    Order Deny,Allow  
  23.    Allow from All  
  24. </Directory>  

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值