CentOS7配置Apache多站点VirtualHost

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

# mkdir /www/test1
# echo "test1" > /www/test1/index.html
# mkdir /www/test2
# echo "test2" > /www/test2/index.html

 //配置虚拟机主机

# cd /etc/httpd/
# mkdir vhost-conf.d
# echo "Includevhost-conf.d/*.conf" >> conf/httpd.conf
# vi /etc/httpd/vhost-conf.d/vhost-name.conf

//添加如下内容


   ServerName example1.com
   ServerAlias example1.com www.example1.com
   DocumentRoot /var/www/test1/
   DirectoryIndex index.html index.php


   Options +Includes -Indexes
   AllowOverride All
   Order Deny,Allow
   Allow from All


   ServerName example2.com
   ServerAlias example2.com www.example2.com
   DocumentRoot /var/www/test2/
   DirectoryIndex index.html index.php


   Options +Includes -Indexes
   AllowOverride All
   Order Deny,Allow
   Allow from All

你可能感兴趣的:(服务器开发)