<IfDefine HAVE_AUTH_MYSQL> <IfModule !mod_auth_mysql.c> LoadModule mysql_auth_module extramodules/mod_auth_mysql.so </IfModule> </IfDefine> <IfModule mod_auth_mysql.c> # # mod_auth_mysql can be used to limit access to documents by checking # data in a MySQL database. # # This will enable user-based MySQL authentication of everything # within /var/www. You'll need to do the following as the MySQL # root user beforehand: # # CREATE DATABASE auth; # USE auth; # CREATE TABLE users ( # user_name CHAR(30) NOT NULL, # user_passwd CHAR(20) NOT NULL, # PRIMARY KEY (user_name) # ); # GRANT SELECT # ON auth.users # TO authuser@localhost # IDENTIFIED BY 'PaSsW0Rd'; # # INSERT INTO users VALUES ('testuser', ENCRYPT('testpass')); # #<Directory /var/www> # AuthName "MySQL authenticated zone" # AuthType Basic # # AuthMySQLUser authuser # AuthMySQLPassword PaSsW0Rd # AuthMySQLDB auth # AuthMySQLUserTable users # AuthMySQLNameField user_name # AuthMySQLPasswordField user_passwd # # require valid-user #</Directory> # This will enable group-based MySQL authentication of everything # within /var/www. You'll need to do the following as the MySQL # root user beforehand: # # CREATE DATABASE auth; # USE auth; # CREATE TABLE users ( # user_name CHAR(30) NOT NULL, # user_passwd CHAR(20) NOT NULL, # user_group CHAR(20) NOT NULL, # PRIMARY KEY (user_name) # ); # GRANT SELECT # ON auth.users # TO authuser@localhost # IDENTIFIED BY 'PaSsW0Rd'; # # INSERT INTO users VALUES ('testuser', ENCRYPT('testpass'), 'user'); # INSERT INTO users VALUES ('testadmin', ENCRYPT('testpass'), 'admin'); # #<Directory /var/www> # AuthName "MySQL group authenticated zone" # AuthType Basic # # AuthMySQLUser authuser # AuthMySQLPassword PaSsW0Rd # AuthMySQLDB auth # AuthMySQLUserTable users # AuthMySQLNameField user_name # AuthMySQLPasswordField user_passwd # AuthMySQLGroupField user_group # # require group admin #</Directory> # Like the above this enables group-based MySQL authentication of # everything within /var/www, but this configuration allows users to # belong to more than one group. You'll need to do the following as # the MySQL root user beforehand: # # CREATE DATABASE auth; # USE auth; # CREATE TABLE users ( # user_name CHAR(30) NOT NULL, # user_passwd CHAR(20) NOT NULL, # PRIMARY KEY (user_name) # ); # CREATE TABLE groups ( # user_name CHAR(30) NOT NULL, # user_group CHAR(20) NOT NULL, # PRIMARY KEY (user_name, user_group) # ); # GRANT SELECT # ON auth.users # TO authuser@localhost # IDENTIFIED BY 'PaSsW0Rd'; # GRANT SELECT # ON auth.groups # TO authuser@localhost # IDENTIFIED BY 'PaSsW0Rd'; # # INSERT INTO users VALUES ('testuser', ENCRYPT('testpass')); # INSERT INTO groups VALUES ('testuser', 'user'); # INSERT INTO users VALUES ('testadmin', ENCRYPT('testpass')); # INSERT INTO groups VALUES ('testadmin', 'admin'); # INSERT INTO groups VALUES ('testadmin', 'user'); # #<Directory /var/www> # AuthName "MySQL group authenticated zone" # AuthType Basic # # AuthMySQLUser authuser # AuthMySQLPassword PaSsW0Rd # AuthMySQLDB auth # AuthMySQLUserTable users # AuthMySQLNameField user_name # AuthMySQLPasswordField user_passwd # AuthMySQLGroupTable groups # AuthMySQLGroupField user_group # # require group user #</Directory> </IfModule>