apache 配置默认首页和多站点配置多域名

在本地安装了wamp环境,默认的根目录是D:\wamp\www,使用起来非常不方便。那如何改变默认的根目录呢

1,找到httpd.conf文件

D:\wamp\bin\apache\Apache2.2.21\conf

2,找到这个地方

# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.

#DocumentRoot "d:/wamp/www/" #修改你的路径
DocumentRoot "D:/webRoot/"

3 修改下面代码


    #
    # 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

    #
    # 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.
    #

#   onlineoffline tag - don't remove
    Order Deny,Allow
    Deny from all
    Allow from 127.0.0.8


4,重启apache

5,如果出现403页面,需要把


    #
    # 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

    #
    # 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.
    #

#   onlineoffline tag - don't remove
    #Order Deny,Allow
    #Deny from all
    Allow from 127.0.0.8


多站点配置

1.编写配置文件

cd /etc/httpd/conf
vi httpd.conf

在httpd.conf的文件末尾加上

Include /etc/httpd/conf/vhost.conf
cd /etc/httpd/conf/conf #目录下新建vhost.conf,
vi vhost.conf #新建文件编辑状态 按i 输入 

输入内容如下:

NameVirtualHost *:80

    ServerName itzls.com
    ServerName www.itzls.com
    DocumentRoot "/var/www/html"
   
    allow from all
   
    DirectoryIndex index.php index.html


    ServerName shop.itzls.com
    DocumentRoot "/var/www/html/shop"
   
    allow from all
   
    DirectoryIndex index.html index.php

按esc 退出输入

:qw #退出并保存vi 编辑器

你可能感兴趣的:(apache 配置默认首页和多站点配置多域名)