Chinaunix首页 | 论坛 | 博客
  • 博客访问: 10482924
  • 博文数量: 2905
  • 博客积分: 20098
  • 博客等级: 上将
  • 技术积分: 36298
  • 用 户 组: 普通用户
  • 注册时间: 2009-03-23 05:00
文章存档

2012年(1)

2011年(3)

2009年(2901)

分类: LINUX

2009-05-06 01:33:34

直接从别的论坛转过来,加入了一些讨论的,希望能够帮助到您
第1步:
我们在/var/www(apache的主页根目录)下建立一个test目录
mkdir /var/www/test

第2步
然后我们编辑httpd.conf
添加
Alias /test"/var/www/test"

Options Indexes MultiViews
AllowOverride AuthConfig #表示进行身份验证
Order allow,deny
Allow from all


#AllowOverride AuthConfig 表示进行身份验证 这是关键的设置

第3步
在/var/www/test创建.htaccess文件
vi /var/www/test/.htaccess

AuthName "frank share web"
AuthType Basic
AuthUserFile /var/www/test/.htpasswd
require valid-user

#AuthName 描述,随便写
#AuthUserFile /var/www/test/.htpasswd
#require valid-user 或者 require user frank 限制是所有合法用户还是指定用户

#密码文件推荐使用.htpasswd,因为apache默认系统对“.ht”开头的文件默认不允许外部读取,安全系数会高一点哦。

第4步

就是创建apache的验证用户

htpasswd -c /var/www/test/.thpasswd frank

#第一次创建用户要用到-c 参数 第2次添加用户,就不用-c参数
如果你们想修改密码,可以如下
htpasswd -m .htpasswd frank

第5步:
ok,重启apache服务,然后访问 如果顺利的话,应该能看到一个用户验证的弹出窗口,只要填入第4步创建的用户名和密码就行



后话,为了服务器的性能,一般不推荐使用AllowOverride AuthConfig或者AllowOverride ALL,因为这会使服务器会不断的去寻找.htaccess,从而影响服务器的效能,一般我们把一些后台管理界面或者其他特殊目录可能需要加验证这个需求。
不错的文章~谢谢~

我来补充:
如果要对AuthUserFile中的用户再进行筛选,比如有两个用户frank,
Paul,则要在.htaccess加上
AuthGroupFile /var/www/test/.htgruop
Require group admin
其中.htgroup为用户组的文件名,文件内容格式为
admin:frank
Require group admin的意思是当用户属于admin组的时候才允许访问

我没有按照你这样的安全配置,因为我在配置的时候跟我在同一局域网上的WINDOWS系统不能访问我的LINUX下的服务器,但却能PING得通我的机子!!不知为什么不能不能访问呢?

我按你的配置做但不能登入。出现如下错误:
authorization required
this server could not verify that you are authorized to access the document requested ,either you supplied the wrong credentials(eg: a bad passward) or your browser does not understand now to supply the credentials required
apache/2.0.46(Radhat)server at localhost port 80

Thank you ,i successed~!~

我也是跟这位兄弟一样的。
 
引用:
-->
作者: guanjun

我按你的配置做但不能登入。出现如下错误:
authorization required
this server could not verify that you are authorized to access the document requested ,either you supplied the wrong credentials(eg: a bad passward) or your browser does not understand now to supply the credentials required
apache/2.0.46(Radhat)server at localhost port 80
-->

如果用Mozilla访问的话就会出现上面的问题,可是,如果用IE或者其他的浏览器就没有问题,请问这是怎么回事啊?如何解决?
谢谢!

上面的楼主
我也按它的做了
可是到第四步我的不执行啊
你们都是怎么做的
给个见解
haoyufu@ioz.ac.cn

输入用户名和密码,出现下面提示,无法登陆

Authorization Required
This server could not verify that you are authorized to access the document requested. Either you supplied the wrong credentials (e.g., bad password), or your browser doesn't understand how to supply the credentials required.


--------------------------------------------------------------------------------

Apache/1.3.33 Server at ftp.scylzx.net Port 80

我得去配置一下,谢谢了!!
阅读(909) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~