Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1802839
  • 博文数量: 293
  • 博客积分: 10127
  • 博客等级: 上将
  • 技术积分: 3029
  • 用 户 组: 普通用户
  • 注册时间: 2010-08-12 19:05
文章分类

全部博文(293)

文章存档

2011年(11)

2010年(282)

我的朋友

分类: LINUX

2010-08-12 21:21:50

本来看文档使用modules.apache.org推荐的mod_auth_mysql 1.9.1 应该是可以的。但貌似文档没提到支持plain text密码。而这个系统需要密码是plain text.只好使用这个mod_auth_mysql 3.0.0了。
需要软件和补丁的下载地址附后.
OS:Redhat ES 3.0
apache-2.2.4,mysql-4.0.x 早已经安装完成。
打补丁mod_auth_mysql 
首先需要打补丁使mod_auth_mysql 支持apache 2.2.x:
wget

patch -p0 < mod_auth_mysql-3.0.0-apr1x.patch
注意:这个是非官方的patch,官方的patch据参考地址2说有,我没有找到。另外一个google到的patch我用了后,编译没问题,访问时会出段错误。
编译安装mod_auth_mysql:
apxs -c -L/usr/lib/mysql -I/usr/include/mysql -lmysqlclient -lm -lz mod_auth_mysql.c
apxs -i mod_auth_mysql.la

配置mod_auth_mysql
add the following directive to httpd.conf:
LoadModule mysql_auth_module modules/mod_auth_mysql.so

在httpd.conf中配置需要认证的目录

Options FollowSymLinks
AllowOverride AuthConfig
Order allow,deny
Allow from all



/var/www/testmysqlauth/.htaccess中内容:

AuthName "MySQL Auth Testing"
AuthType Basic
AuthUserFile /dev/null
AuthBasicAuthoritative off

AuthMySQLEnable On
AuthMySQLHost localhost
AuthMySQLPort 3306
AuthMySQLSocket /tmp/mysql.sock
AuthMySQLUser   myuser
AuthMySQLPassword mypass
AuthMySQLDB mydb
AuthMySQLUserTable usertable
##AuthMySQLUserCondition
AuthMySQLNameField username
AuthMySQLPasswordField password
AuthMySQLNoPasswd Off
AuthMySQLPwEncryption none
## AuthMySQLPwEncryption none | crypt | scrambled | md5 | aes | sha1
AuthMySQLSaltField <>
AuthMySQLGroupTable usertable
###AuthMySQLGroupCondition
AuthMySQLGroupField username
##AuthMySQLKeepAlive Off
AuthMySQLAuthoritative On
##AuthMySQLCharacterSet

require valid-user


此配置使用了localhost 上mysql 的数据库mydb中的usertable表,其中有2个字段username,password.
password字段密码是明文。
至此,配置成功.restart apache .测试通过。

注意问题:
注意红色字体部分AuthUserFile /dev/null
如果没有这行,apache的error_log中会出现这样的错误:
[error] Internal error: pcfg_openfile() called with NULL filename
[error] [client ip] (9)Bad file descriptor: Could not open password file: (null)
如果没有AuthBasicAuthoritative off
会出现错误:
[error] [client ip] user yourusername not found:



相关地址:
Apache 2.2.3/2.2.4编译
ubuntu 6.10 安装后记(六)- MySQL 5.0.x,Apache 2.2.3/2.2.4,Firebird ,PHP 5.2.0/5.2.1 的安装


下载地址
Apache 下载地址:

mod_auth_mysql 下载地址:

Mysql下载地址:


参考地址1:


参考地址2:
阅读(4309) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~