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

使用mysql为apache做用户验证的实践

apache版本:1.3.28

  所需模块:mod_auth_mysql

  下载站点:ftp://ftp.kciLink.com/pub/mod_auth_mysql.c.gz

  apache要求 DSO方式编译安装,具体安装方法本论坛有介绍,apache安装在/usr/local/apache目录下,mysql假设安装在了/usr/local/mysql目录下.

  #cd /usr/local/src

  #wget ftp://ftp.kciLink.com/pub/mod_auth_mysql.c.gz

  #gunzip mod_auth_mysql.c.gz

  #/usr/local/apache/bin/apxs \

  −c −I/usr/local/mysql/include \

  −L/usr/local/mysql/lib/mysql \

  −lmysqlclient −lm mod_auth_mysql.c

  #cp mod_auth_mysql.so /usr/local/apache/libexec/

  编辑httpd.conf,添加

  LoadModule mysql_auth_module libexec/mod_auth_mysql.so

  AddModule mod_auth_mysql.c

  ##让apache启动时加载mod_auth.mysql模块

  <directory />

  AuthType Basic

  AuthUserfile /dev/null

  AuthName Testing

  AuthGroupFile /dev/null

  AuthMySQLHost localhost

  AuthMySQLCryptedPasswords Off

  AuthMySQLUser root

  AuthMySQLDB users

  AuthMySQLUserTable user_info

  require valid−user

  </Directory>

  ###结束###

  准备mysql

  /usr/local/mysql/bin/mysql -u username -p < authmysql.sql

  下面是authmysql.sql的内容

  create database users;

  use users;

  CREATE TABLE user_info (

  user_name CHAR(30) NOT NULL,

  user_passwd CHAR(20) NOT NULL,

  user_group CHAR(10),

  PRIMARY KEY (user_name)

  );

  /usr/local/mysql/bin/mysql -u username -p

  mysql>use users;

  mysql>insert into user_info values('username','password','group');

  打开浏览器http://domainname/本文来自:http://www.xiaoyaxiao.com/2095.html
发表您的高见!
Apache
IIS
Nginx
Tomcat
如果你遇到web 服务器难题:
访问www.zzzyk.com 试试
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,