CentOS7配置Apache多站点VirtualHost

来源:互联网 发布:知乎问答 能挣钱吗 编辑:程序博客网 时间:2024/05/03 07:06

原文链接: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
原创粉丝点击