Apache的目录属性

Apache的目录属性

前言

我们之前见过了Apache的工作模式,现在我们来瞧瞧这个目录属性,那么什么是目录属性呢?我们继续使用刚刚的环境。并开启一台win10虚拟机。

目录属性

目录的权限设置使用<Directory 目录路径>和< /Directory > 这对语句为主目录或虚拟目录设置权限。它们是一-对容器语句,必须成对出现,它们之间封装的是具体的设置目录权限语句,这些语句仅对被设置目录及其子目录起作用。

目录属性的参数

参数作用
Options设置在特定目录使用哪些特性
AllowOverride允许存在于htaccess文件中的指令类型
Require设置目录的访问控制
Indexes当用户访问该目录时,但没有指定要访问哪个文件,而且目录下不存在默认网页时,返回目录中的文件和子目录列表
MultiViews内容协商的多重视图,Apache的一 个智能特性。当访问目录中不存在的对象时
ExecCGI允许在该目录下执行CGI脚本
FollowSymLinks在该目录下允许文件系统使用符号连接
Includes允许服务器端包含功能
IncludesNoExec允许服务器端包含功能,但禁止执行CG
All包含除了MultiViews之外所有特性,如果没有Options语句,默认为All

实验步骤

1.查看目录属性

[root@localhost bin]# vim /etc/httpd.conf
DocumentRoot "/usr/local/httpd/htdocs"
<Directory "/usr/local/httpd/htdocs">
    #
    # 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.4/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:
    #   AllowOverride FileInfo AuthConfig Limit
    #
    AllowOverride None

    #
    # Controls who can get stuff from this server.
    #
    Require all granted
</Directory>

2.查看站点里面的文件,并关闭防火墙

[root@localhost bin]# cd /usr/local/httpd/htdocs/
[root@localhost htdocs]# ls
index.html
[root@localhost htdocs]# cat index.html 
<html><body><h1>It works!</h1></body></html>
[root@localhost htdocs]# systemctl stop firewalld 
[root@localhost htdocs]# setenforce 0

3.在win10主机里面测试

在这里插入图片描述

4.将index.html换成a.html

[root@localhost htdocs]# mv index.html a.html
[root@localhost htdocs]# ls
a.html
[root@localhost htdocs]# touch b.html c.html d.html
[root@localhost htdocs]# ls
a.html  b.html  c.html  d.html

在win10主机中查看一下结果

在这里插入图片描述

在这里插入图片描述

5.将/etc/passwd建立一个连接到站点目录下

[root@localhost htdocs]# ln -s /etc/passwd ./
[root@localhost htdocs]# ls
a.html  b.html  c.html  d.html  passwd

在win10主机中查看

在这里插入图片描述

在这里插入图片描述

实验总结

我们可以通过Apache的目录属性的特点,将服务器的资源以这样的一种形式分享给别人,节省了不少资源,而且还省时省事。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值