Linux+Apache实现用户身份认证
(二)mod—auth—mysql模块完成身份认证功能,由于Apache + PHP + MySQL已经被许多网站的建设者当作是建设中小型网络数据库的黄金组合,因而mod—auth—mysql的功能也就显得尤其强大。它主要是把允许访问资源的组名、用户名、用户口令以文本文件的方式存放。
1.建立认证用的数据库
2.建立认证用的表,并插入一行数据
在http.cont中加入 Auth—MySQL—Info [host] [username][Password]
其中username和password是MySQL数据库用户的用户名和口令。
4.创建 .htaccess文件
使用这种认证方法的最大优点是PHP提供了大量对MySQL数据库进行操作的函数,可以方便地进行远程管理。
1.建立认证用的数据库
prompt〉mysqladmin create http—auth
2.建立认证用的表,并插入一行数据
3.配置Apacheprompt〉mysql http—auth mysql〉create table mysql—auth ( -〉sername char(25) NOT NULL, -〉passwd char(25), -〉groups char(25), -〉primary key (usrname) -〉); mysql〉insert mysql—auth (username,passwd,groups) -〉values (″lkch″,PASSWD(″hello″),″ptisi″);
在http.cont中加入 Auth—MySQL—Info [host] [username][Password]
其中username和password是MySQL数据库用户的用户名和口令。
4.创建 .htaccess文件
最后这句话表示认证时口令的形式,分别表示不加密、DES加密方式和MySQL的Password()加密。AuthName ″This is a test!″ AuthType Basic Auth—MySQL on Auth—MySQL—Db http—auth Auth—MySQL—Password—Table mysql—auth Auth—MySQL—Group—Table mysql—auth Auth—MySQL—Username—Field username Auth—MySQL—Password—Field passwd Auth—MySQL—Group—Field groups Auth—MySQL—Encryption—Types Plaintext,Crypt—DES,MySQL
使用这种认证方法的最大优点是PHP提供了大量对MySQL数据库进行操作的函数,可以方便地进行远程管理。
0
相关文章