linux 下的 apache 绑定多个域名

web开发作者:dayu日期:9天前点击:4
  • #<VirtualHost94.249.188.58:80>
  • #ServerAdminwebmaster@dummy-host.example.com
  • #DocumentRoot/www/docs/dummy-host.example.com
  • #ServerNamedummy-host.example.com
  • #ErrorLoglogs/dummy-host.example.com-error_log
  • #CustomLoglogs/dummy-host.example.com-access_logcommon
  • #</VirtualHost>

  • 在后面添加:

    代码
    1. *IP访问/var/www/html/dir目录
      <VirtualHost94.249.188.58:80>
    2. ServerAdmin webmaster@dummy-host.example.com
    3. DocumentRoot/var/www/html/dir
    4. ServerName94.249.188.58
    5. ErrorLoglogs/dummy-host.example.com-error_log
    6. CustomLoglogs/dummy-host.example.com-access_logcommon
    7. </VirtualHost>
    8. *wuleilei.com与www.wuleilei.com访问/var/www/html/dir1目录
    9. <VirtualHost94.249.188.58:80>
    10. ServerAdminwebmaster@dummy-host.example.com
    11. DocumentRoot/var/www/html/dir1
    12. ServerNamewuleilei.com
    13. ServerAliaswww.wuleilei.com
    14. ErrorLoglogs/dummy-host.example.com-error_log
    15. CustomLoglogs/dummy-host.example.com-access_logcommon
    16. </VirtualHost>
    17. *wuleilei.net与www.wuleilei.net访问/var/www/html/dir2目录
    18. <VirtualHost94.249.188.58:8081>
    19. ServerAdminwebmaster@dummy-host.example.com
    20. DocumentRoot/var/www/html/dir2
    21. ServerNamewuleilei.net
    22. ServerAliaswww.wuleilei.net
    23. ErrorLoglogs/dummy-host.example.com-error_log
    24. CustomLoglogs/dummy-host.example.com-access_logcommon
    25. </VirtualHost>

    附:如果想开其他端口,请按照如下操作(以8080端口为例):

    1、打开http.conf,查找Listen 80,在下面一行添加Listen 8080;

    2、在文件末尾添加如下代码:

    代码
    1. <VirtualHost94.249.188.58:8080>
    2. ServerAdminwebmaster@dummy-host.example.com
    3. DocumentRoot/var/www/html/dir3
    4. ServerNamewuleilei.com
    5. ServerAliaswww.wuleilei.com
    6. ErrorLoglogs/dummy-host.example.com-error_log
    7. CustomLoglogs/dummy-host.example.com-access_logcommon
    8. </VirtualHost>

    这样就将www.wuleilei.com:8080绑定到/var/www/html/dir3目录了。


    本站原创,转载请标明:来自追梦博客(http://www.wuleilei.com/)

    本文地址:http://www.wuleilei.com/Blog/240


    linux 下的 apache 绑定多个域名

    原文地址:http://www.cnblogs.com/zyjfire/p/7233299.html


    下一篇       上一篇