實戰apache使用者驗證(轉)

post0發表於2007-08-09
實戰apache使用者驗證(轉)[@more@]

本文主要介紹了包含在apache發行版本內的使用者驗證模組---auth,auth_db

驗證模組的使用是很簡單的就以下三步

1、建立用於儲存使用者/密碼的檔案

2、配置apache以使用那個檔案做使用者驗證

3、可選的建立一個組檔案

1、apache_1.3.28的安裝。

shell>./configure --prefix=/www --disable-module=all --enable-module=access --enable-module=so --enable-shared=max --enable-module=auth_anon --enable-module=auth --enable-module=auth_db --enable-module=auth_dbm --enable-module=digest --enable-module=alias --enable-module=log_config --enable-module=dir --enable-module=mime

shell>make

shell>make intall

2、建立需要的目錄

mkdir /www/auth

mkdir /www/authdb

chown nobody:nobody /www/auth /www/authdb

3、編輯httpd.conf

Alias /auth /www/auth

Alias /authdb /www/authdb

AllowOverride AuthConfig

AllowOverride Authconfig

AuthType Basic

4、在/www/auth,/www/authdb中分別建立.htaccess檔案

vi /www/auth/.htaccess

AuthName "password file auth"

AuthUserFile /www/authfile/password

AuthGroupFile /www/authfile/group

Require group test

vi /www/authdb/.htaccess

AuthName "db auth"

AuthDBUserFile /www/authfile/dbuser.dat

Require username1

5、建立密碼檔案

/www/bin/htpasswd -c /www/authfile/password username1

/www/bin/htpasswd /www/authfile/password username2

建立組檔案

echo "test: username1 username2" >> /www/authfiile/group

6、建立密碼資料庫用於資料庫驗證

/www/bin/dbmmanage /www/authfile/dbuser.dat adduser username

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/8225414/viewspace-938027/,如需轉載,請註明出處,否則將追究法律責任。

相關文章