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 修改下面代码

<Directory "D:/webRoot/">
    #
    # 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

</Directory>

4,重启apache

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

<Directory "D:/webRoot/">
    #
    # 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

</Directory>

多站点配置

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
<VirtualHost *:80>
    ServerName itzls.com
    ServerName www.itzls.com
    DocumentRoot "/var/www/html"
   <directory "/var/www/html">
    allow from all
   </directory>
    DirectoryIndex index.php index.html
</VirtualHost>
<VirtualHost *:80>
    ServerName shop.itzls.com
    DocumentRoot "/var/www/html/shop"
   <directory "/var/www/html/shop"">
    allow from all
   </directory>
    DirectoryIndex index.html index.php
</VirtualHost>

按esc 退出输入

:qw #退出并保存vi 编辑器
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 服务器https配置 配置https操作说明文档 1、查看服务器环境配置(tomcat和apache合并使用) 2...
    南京杨小兵阅读 8,943评论 0 9
  • 《六项精进》打卡第156天 姓名:李月红 公司: 宁波市镇海承迪文具有限公司 组别:感谢二组 【知~学习】 背《六...
    嗨_李迪阅读 224评论 0 0
  • 近日,外媒报道称,有一份谷歌的新专利遭到曝光。专利文件中描述了这样一款设备,它能够支持交互式辅助会话,能将图片发送...
    瑞锋科讯阅读 245评论 0 0
  • 说起近五年来我体会最深、最引以为豪的事,就是我在主抓全市安全生产长效管理工作后,使得安全生产长效管理迈上了新台阶。...
    凤凰磐石阅读 845评论 0 0
  • 虽然这些年不看电视剧,但那些狗血的办公室斗争还是知道一点,然而到了现在公司,马上快一年了,还真是见识到了种种。一开...
    cellardoor阅读 134评论 0 0