Apache MySQL Authentication

mod_auth_mysql will need to be loaded.

in vhost.conf add:

AuthType Basic
AuthName “Auth required”
AuthMySQLHost localhost
AuthMySQLUser auth_user
AuthMySQLPassword mypassword
AuthMySQLDB mysqlauth
AuthMysqlUserTable clients
AuthMySQLNameField username
AuthMySQLPasswordField passwd
AuthMySQLPwEncryption none
AuthMySQLEnable on
require valid-user

Then in MySQL:

create database mysqlauth;

use mysqlauth;

CREATE TABLE `clients` ( `username` varchar(25) NOT NULL default ”, `passwd` varchar(25) NOT NULL default ”, `groups` varchar(25) NOT NULL default ”, PRIMARY KEY (`username`), KEY `groups` (`groups`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1;

INSERT INTO `clients` VALUES (‘bob’, ‘testpass12′, ‘testgroup’);

grant all on mysqlauth.* to auth_user@localhost identified by ‘mypassword';
flush privileges;

You can leave a response, or trackback from your own site.

Leave a Reply