apache 设置目录权限控制

1。首先要有apache 的认证模块,默认都会安装。

2. 编辑httpd.conf文件 ,修改工作目录下的配置,将AllowOverride 更改为AuthConfig

<Directory /data/mrtgwww/> Options Indexes FollowSymLinks AllowOverride AuthConfig Order allow,deny Allow from all </Directory>

3.用htpasswd创建一个密码文件,比如文件名叫 my.pass

创建

htpasswd -c -b my.pass myusername mypassword

添加用户

htpasswd -b my.pass newusername newpassword

4.将my.pass移动到一个非发布路径下之外的任何目录中,比如 /home/下

5. 在工作目录创建.htaccess 文件,文件内容为

AuthName "My Authorization Directory" # 显示名称 AuthType Basic # 认证类型 AuthUserFile /home/my.pass #认证文件位置 Require valid-user

6.测试,即可出现输入用户名密码的对话框

在windows上只需要在路径上作出相应改变

AuthName "My Authorization Directory"

AuthType Basic
AuthUserFile c:/home/my.pass
Require valid-user

还要记住不能用#作注释,否则会出现错误

C:/Program Files/Apache Group/Apache2/htdocs/.htaccess: AuthName takes one argument, The authentication realm (e.g. "Members Only")

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值