Apache 的访问权限控制 <?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

 

2009-03-17-------- 第一天

Apache 的访问权限控制

简单介绍:这是一个 apache 的系列配置文档,配置 apache 的认证授权,此篇为第一篇。

认证类型: basic 基本认证(常用)   digest 摘要认证

认证指令:

1.1 authname   受保护域名称

1.2 authtype   认证方式

1.3 authuserfile 认证口令文件位置

1.4 authgroupfile 认证组文件位置

授权指令:

2.1 require user 授权给指定用户

2.2 require group 授权给指定组

2.3 require valid-user 授权给认证口令文件用户

建立用户库:

3.1 基本认证:

#htpasswd –c aurhfile username

#htdbm –TDB –c authfile username

3.2 摘要认证

#htdigest –c authfile username

口令文件格式: username:password

组文件格式: groupname:user1 user2

 

  具体配置步骤:

1.   创建口令文件

Cd /etc/httpd/

Htpasswd –c httppwd test

Htpasswd  httppwd bbs( 不要 -c 参数会覆盖上一个 )

 

Vi httpd.conf

修改为:

<Directory “/var/www/test”>

   Optinons Indexes MultiViews

    AllowOverride None

    authname “test”

authtype basic

authuserfile /etc/httpd/httppwd

require user test

   </Directory>               ## 只授权 test 用户访问

 

Service httpd restart

 

#####################################

 

Vi httpd.conf

修改为:

<Directory “/var/www/test”>

   Optinons Indexes MultiViews

   AllowOverride None

    authname “test”

authtype basic

authuserfile /etc/httpd/httppwd

require valid-user

   </Directory>    ## 口令文件所有用户都可以访问

 

Service httpd restart

 

#########################################

 

Vi httpgrp

添加:

admin: test bbs

wq!

 

Vi httpd.conf

修改为:

<Directory “/var/www/test”>

   Optinons Indexes MultiViews

   AllowOverride None

    authname “test”

authtype basic

authuserfile /etc/httpd/httppwd

authgroupfile /etc/httpd/httpgrp

require group admin

   </Directory>     ##admin 组可以访问

 

   Service httpd restart

 

########################################

 

不对之处请大家多多批评。 *-*