CentOS 7 配置虚拟主机站点

1.进入/etc/httpd/conf 下 将httpd.conf 打开。
2.将DocumentRoot注释掉。(将ServerName 打开要不会有错误警告)。
3.将虚拟主机站点配置包含进来:Include conf.d/vhosts.conf。然后保存关闭httpd.conf。
4.进入/etc/httpd/conf.d 下新建并打开vhosts.conf。
5.配置虚拟主机站点如下:

<VirtualHost 192.168.10.12:80>
ServerName www.a.com
DocumentRoot /var/www/1012
<Directory "/var/www/1012">
AllowOverride None
Order allow,deny
Allow from all

<VirtualHost 192.168.100.12:80>
ServerName www.a.com
DocumentRoot /var/www/a.com

     <Directory "/var/www/a.com">
             Options Indexes FollowSymLinks
             AllowOverride None
             Order allow,deny
             Allow from all
     </Directory>

<VirtualHost 192.168.100.12:8080>
ServerName www.a.com
DocumentRoot /var/www/8080
<Directory "/var/www/8080">
Order allow,deny
Allow from all

<VirtualHost 192.168.100.12:80>
ServerName www.b.net
DocumentRoot /var/www/b.net
<Directory "/var/www/b.net">
Order allow,deny
Allow from all

<VirtualHost 192.168.100.12:80>
ServerName www.c.org
DocumentRoot /var/www/c.org

<VirtualHost 192.168.100.12:80>
ServerName www.d.cn
DocumentRoot /var/www/d.cn

6.最后重启httpd服务:systemctl restart httpd.service

posted @ 2017-01-05 14:47  TK-D小跆风  阅读(405)  评论(0编辑  收藏  举报