当前位置:web 服务器 > Apache >>

Apache-2.2.4+mod_auth_mysql3.0.0+mysql4.0.x的配置

千辛万苦Google后,终于把Apache 2.2.x + mod_auth_mysql配置出来了。记录下来.

  本来看文档使用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 http://cvs.mandriva.com/cgi-bin/viewvc.cgi/SPECS/apache-mod_auth_mysql/mod_auth_mysql-3.0.0-apr1x.patch

  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中配置需要认证的目录

  <Directory "/var/www/testmysqlauth">

  Options FollowSymLinks

  AllowOverride AuthConfig

  Order allow,deny

  Allow from all

  </Directory>

  /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

  <limit GET POST>

  require valid-user

  </limit>

  此配置使用了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 下载地址:

  http://httpd.apache.org

  mod_auth_mysql 下载地址:

  http://sourceforge.net/projects/modauthmysql

  Mysql下载地址:

  http://www.mysql.com

  参考地址1:

  http://oldtimeynerd.net/index.php/Error_Messages_and_Answers

  参考地址2:

  http://www.vhcs.net/new/modules/newbb/viewtopic.php?topic_id=5028&start=10本文来自:http://www.xiaoyaxiao.com/79991.html
发表您的高见!
Apache
IIS
Nginx
Tomcat
如果你遇到web 服务器难题:
请访问www.zzzyk.com 试试
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,