Wednesday, October 6, 2010

Apache Access Control with User/Password protected directories with MYSQL

 add the following to httpd.conf file 

     AuthType Basic
     AuthName " protected directories "
     AuthMySQLHost localhost
     AuthMySQLUser root
     AuthMySQLPassword  dbpassword
     AuthMySQLDB http_auth
     AuthMysqlUserTable  user_auth
     AuthMySQLNameField user_name
     AuthMySQLPasswordField user_passwd
     AuthMySQLNoPasswd Off
     AuthMySQLPwEncryption crypt
     AuthMySQLPwEncryption none
     AuthMySQLEnable on
     require valid-user
    


MYSQL
* mysql -h localhost -u root -ppassword
    * mysql> create database http_auth;
* mysql> use  http_auth;
    * mysql> create table user_auth ( user_name char(30) NOT NULL,user_passwd char(60) NOT NULL,user_group char(25),primary key (user_name) );
    * mysql> insert into user_auth values('Nikhil','supersecret','Admin');
and restart apache .....
 mod_auth_mysql*.*rpm need to be installed
And make sure this line is included in the conf file httpd.conf
LoadModule mysql_auth_module modules/mod_auth_mysql.so

No comments: