服务器平台为ubuntu feisty,首先确认apache2已经安装好。
然后安装auth-mysql支持并启用此模块:
sudo aptitude install libapache2-mod-auth-mysql
sudo a2enmod auth_mysql
要建立一个数据库用于认证,并建立一个用户表存贮用户信息。
mysql -uroot
create database svn;
grant all on svn.* to svn@localhost identified by ‘mypwd’;
flush privileges;
use svn;
create table auth(
`username` varchar(25) NOT NULL default ”,
`passwd` varchar(25) NOT NULL default ”,
`groups` varchar(25) NOT NULL default ”,
PRIMARY KEY (`username`),
KEY `groups` (`groups`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
然后修改site文件:
Auth_MySQL_Info localhost
">
Options +Indexes FollowSymLinks MultiViews
AllowOverride AuthConfig Options FileInfo Limit
Order allow,deny
Allow from all
创建.htaccess文件:
AuthUserFile /dev/null
AuthBasicAuthoritative off
AuthMYSQL on
AuthMySQL_Authoritative on
AuthMySQL_DB svn
AuthMySQL_Password_Table auth
AuthMySQL_Group_Table auth
AuthMySQL_Empty_Passwords off
AuthMySQL_Encryption_Types Plaintext Crypt_DES
AuthName ""
AuthType Basic
require valid-user
#or
require group group group1
注意问题:
注意这个部分AuthUserFile /dev/null
如果没有这行,apache的error_log中会出现这样的错误:
[error] [client ip] (9)Bad file descriptor: Could not open password file: (null)
如果没有AuthBasicAuthoritative off
会出现错误:
[error] [client ip] user yourusername not found:
参考:
http://www.howtoforge.com/mod_auth_mysql_apache2_debian
http://www.linuxmine.com/79991.html
发表回复