zoukankan      html  css  js  c++  java
  • apache:一个ip绑定多个域名的问题(续)

    •   基于域名的虚拟主机,通过ServerName区分域名

    1、  在httpd.conf文件中启动虚拟主机的配置

    #Include conf/extra/httpd-vhosts.conf (取消注释.即把#去掉)

    2、配置httpd-vhosts

    <VirtualHost *:80>

             DocumentRoot ""   #网站的根目录

             ServerName www.abc.com      #此处替换对应网站的域名

             ServerAlias abc.com. *.abc.com   #网站别名

             DirectoryIndex index.html index.php

             <Directory>

                       Options FollowSymLinks +Indexes

                       AllowOverride None

                       Order allow,deny

                       Allow from all

             </Directory>

    </VirtualHost >

    说明:

    Options:配置在特定目录使用哪些特性,常用的值和基本含义如下: 

          ExecCGI: 在该目录下允许执行CGI脚本。 

          FollowSymLinks: 在该目录下允许文件系统使用符号连接。 

          Indexes: 当用户访问该目录时,如果用户找不到DirectoryIndex指定的主页文件(例如index.html),则返回该目录下的文件列表给用户。 

          SymLinksIfOwnerMatch: 当使用符号连接时,只有当符号连接的文件拥有者与实际文件的拥有者相同时才可以访问。 

    AllowOverride:允许存在于.htaccess文件中的指令类型(.htaccess文件名是可以改变的,其文件名由AccessFileName指令决定): 
          None: 当AllowOverride被设置为None时。不搜索该目录下的.htaccess文件(可以减小服务器开销)。 

          All: 在.htaccess文件中可以使用所有的指令。 

    Order:控制在访问时Allow和Deny两个访问规则哪个优先: 

         Allow:允许访问的主机列表(可用域名或子网,例如:Allow from 192.168.0.0/16)。 

         Deny:拒绝访问的主机列表。 

    DirectoryIndex index.html index.htm index.php #主页文件的设置(本例将主页文件设置为:index.html,index.htm和index.php) 

    3、在hosts文件添加多对ip和域名的对应关系

    如:

       127.0.0.1       localhost

       127.0.0.1       www.abc.com   (与ServerName同名。可以替换你要设置的域名)

    4、重启apache

    •  关于在win7中的配置虚拟主机(我的是appserv集成的php环境)

    更改第2步骤:

    <VirtualHost *:80>

             DocumentRoot ""   #网站的根目录

             ServerName www.abc.com     #此处替换对应网站的域名

             ServerAlias abc.com. *.abc.com   #网站别名

             DirectoryIndex index.html index.php

    </VirtualHost >

  • 相关阅读:
    hdoj--2098--分拆素数和(枚举)
    hdoj--3594--Cactus(tarjan)
    hdoj--1251--统计难题(字典树)
    hdoj--2534--Score(gcd)
    nyoj--1185--最大最小值(线段树)
    hdoj--1166--敌兵布阵(线段树)
    hdoj--1754--I Hate It(线段树)
    poj--2234--Matches Game(尼姆博弈)
    lightoj--1005--Rooks(组合数)
    SPOJ
  • 原文地址:https://www.cnblogs.com/mackxu/p/2439917.html
Copyright © 2011-2022 走看看