apache下配置认证用户

来源:互联网 发布:书包 淘宝 编辑:程序博客网 时间:2024/05/04 00:41

有时候我们需要给我apache服务器下制定的目录加上用户认证,方便一些而用户进行文件的浏览。配置如下:

1 设置用户

1
htpasswd -c file_path user_name

回车之后输入密码即可,请确保命令中的file _path有其他用户读的权限。

2 设置Apache

在/etc/apache2/apache2.conf或/etc/httpd/conf/httpd.conf中添加以下内容

1
2
3
4
5
6
7
8
<Directory /var/www/html/picture>
AuthName "Important Directory"  #登录时提示的内容
AuthType Basic  #认证方式
IndexOptions Charset=GB2312  #网页编码
Options Indexes FollowSymLinks MultiViews #以目录形式展示
AuthUserFile /opt/.apache_user #用户文件,1中file_path
Require valid-user 
</Directory>


若要隐藏服务器标示,请在配置文件中加入以下信息:

1
2
ServerSignature Off
ServerTokens Prod

更多文章请前往小胖轩.

0 0
原创粉丝点击