zoukankan      html  css  js  c++  java
  • apache一个IP多个站点的配置方法

      在日常的网站发布中很多情况下都无法做到一个IP对应一个站点,在IP4的情况下IP的资源是相对有限的。然而作为最流行的Apache自然也考虑到这种情况,那么接下来看看apache服务器怎么配置一个IP多个站点。

      在httpd.conf中找到 "# Virtual hosts",并添加如下行

        ServerName 你的域名

        HostNameLookups off

      例子  

    NameVirtualHost 192.168.1.104
    
    <VirtualHost 192.168.1.104>
            ServerName www.php.com
            ServerAdmin test@gmail.com
            DocumentRoot /data/www1/
            DirectoryIndex index.php index.html index.htm index.shtml
            Errorlog /usr/local/apache2/logs/wwwError_log
            Loglevel warn
            HostNameLookups off
            <Directory /data/www1/>
              AllowOverride None
              Order allow,deny
              Allow from all
            </Directory>
    </VirtualHost>
    
    <VirtualHost 192.168.1.104>
            ServerName bbs.php.com
            ServerAdmin test@gmail.com
            DocumentRoot /data/www2/
            DirectoryIndex index.php index.html index.htm index.shtml
            Errorlog /usr/local/apache2/logs/bbsError_log
            Loglevel warn
            HostNameLookups off
            <Directory /data/www2/>
              AllowOverride None
              Order allow,deny
              Allow from all
            </Directory>
    </VirtualHost>

      上述的例子IP都是192.168.1.104,域名分别是www.php.com和bbs.php.com。因而可知apahce是通过ServerName来识别同一个IP下的不同站点的。

      在实际应用中你只需要将IP192.168.1.104、域名www.php.com和bbs.php.com分别改成你的IP和域名即可。

  • 相关阅读:
    欧拉回路的判断(hdu1878)其一
    最长公共子序列(不是子串)hdu1159
    线段树(hdu1166)
    记忆化搜索(hdu1078)
    分考场问题。。。
    hdu2087
    cf540C
    x86 寄存器 | DPL,RPL,CPL 之间的联系和区别
    深度学习 | 训练网络trick——mixup
    python | Argparse中action的可选参数store_true,store_false到底是什么意思?
  • 原文地址:https://www.cnblogs.com/rwxwsblog/p/4590654.html
Copyright © 2011-2022 走看看