配置3个站点实战

域名

www.test.org    /var/html/www

blog.test.org    /var/html/blog

bbs.test.org    /var/html/bbs

[root@A-host extra]# mkdir /var/html/{www,blog,bbs} -p

[root@A-host extra]# touch /var/html/{www,blog,bbs} /index.html

[root@A-host extra]# for name  in www blog bbs;do echo "http://$name.test.org">/var/html/$name/index.html;done     
[root@A-host extra]# for name  in www blog bbs;do cat /var/html/$name/index.html;done                         
http://www.test.org
http://blog.test.org
[root@A-host extra]# vim httpd-vhosts.conf

<VirtualHost *:80>
    ServerAdmin honey-z@qq.com
    DocumentRoot "/var/html/www"
    ServerName www.test.org
    ServerAlias test.org
    ErrorLog "logs/www-error_log"
    CustomLog "logs/www-access_log" common
</VirtualHost>

<VirtualHost *:80>
    ServerAdmin honey-z@qq.com
    DocumentRoot "/var/html/blog"
    ServerName blog.test.org
    ErrorLog "logs/blog-error_log"
    CustomLog "logs/blog-access_log" common
</VirtualHost>

<VirtualHost *:80>
    ServerAdmin honey-z@qq.com
    DocumentRoot "/var/html/bbs"
    ServerName bbs.test.org
    ErrorLog "logs/bbs-error_log"
    CustomLog "logs/bbs-access_log" common
</VirtualHost>
#编辑主配置文件httpd.conf打开#添加
Include conf/extra/httpd-mpm.conf
Include conf/extra/httpd-vhosts.conf

<Directory "/var/html">
    Options -Indexes FollowSymLinks
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>
[root@A-host apache]# bin/apachectl -t
[root@A-host apache]# bin/apachectl graceful