apache下虚拟主机的配置

 1. 启用httpd-vhosts.conf

      在httpd.confg文件中找到
      # Virtual hosts
      #Include conf/extra/httpd-vhosts.conf(这里将前面的#去掉即可启用虚拟主机
     ! 如果是使用套件AppServ之类的还需要启用mod_vhost_alias.so模块(#LoadModule vhost_alias_module modules/mod_vhost_alias.so) 

  2. 配置httpd-vhosts.conf
       

<VirtualHost *:80>

    #配置网站站点根目录(例如:d:/mywebsite)

   DocumentRoot "d:/mywebsite"

    #配置网站域名

   ServerName www.website.com

   #下面配置网站根目录的相关属性('/' <=> 'd:/mywebsite' )

 

   <Directory />

        #配置在没有指定网站首页面时,是否显示目录结构列表

        Options index FollowSymLinks

        #配置修改权限(None 表示不允许)

        AllowOverride None

        #设置访问权限

        Order allow,deny

        Allow from all

        #配置网站的首页面

        DiectoryIndex index.html index.htm index.php

        #配置网站404错误页面

        errorDocument 404 /404.html

   </Directory>

</VirtualHost>

 Options index FollowSymLinks: 如果这里有index则指明可以显示目录结构列表,如果不想显示目录结构料,有如下几种方式:
  ① 将index直接去掉即可
  ②httpd.confg文件中找到如下内容
    <Directory "C:/AppServ/www">
    #这里C:/AppServ/www是apache服务器默认的根目录
    # Possible values for the Options directive are "None", "All",
    # or any combination of:
    #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
    #
    # Note that "MultiViews" must be named *explicitly* --- "Options All"
    # doesn't give it to you.
    #
    # The Options directive is both complicated and important.  Please see
    # http://httpd.apache.org/docs/2.2/mod/core.html#options
    # for more information.
    #
    Options Indexes FollowSymLinks MultiViews ExecCGI

    #
    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be "All", "None", or any combination of the keywords:
    #   Options FileInfo AuthConfig Limit
    #
    AllowOverride All

    #
    # Controls who can get stuff from this server.
    #
    Order allow,deny
    Allow from all

</Directory>
 Options Indexes FollowSymLinks MultiViews ExecCGI中的index加‘-’即可,即Options -Indexes FollowSymLinks MultiViews ExecCGI,此时整个apache服务器都禁止目录浏览
  ③在虚拟主机中的 Options index FollowSymLinks中的index前加‘-’即可,即 Options -index FollowSymLinks
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值