KoppiePeest

Willekeurige urls of gevonden fragmenten om te onthouden of terug te vinden

Posts Tagged ‘htaccess’

HTTP 401 using MySQL

Posted by JephapE op 6 mei 2010

2 things: Webserver config & Database tables

1: Webserver config, in htaccess or VirtualHost.

# mod_auth_mysql - the .htacccess
AuthBasicAuthoritative    Off
AuthUserFile              /dev/null
Auth_MySQL_Authoritative  on

AuthName  "MySQL Testing"
AuthType  Basic

Auth_MySQL  On

Auth_MySQL_Host      localhost
Auth_MySQL_User      apache
Auth_MySQL_Password  htdatabase
Auth_MySQL_DB        auth_apache

Auth_MySQL_Password_Table  users
Auth_MySQL_Group_Table     groups

Auth_MySQL_Username_Field htusername
Auth_MySQL_Password_Field htpassword
Auth_MySQL_Group_Field    htgroupname

Auth_MySQL_Empty_Passwords  off
Auth_MySQL_Encryption_Types  PHP_MD5 Crypt

# require valid-user
require group admins

2: Database tables

-- mod_auth_mysql - The MySQL tables
-- First:
-- CREATE DATABASE ...;
-- CREATE USER ...;
-- GRANT ALL for database to user ...;
-- FLUSH PRIVILEGES;
-- ... and then:

CREATE TABLE groups (
  htusername varchar(32) NOT NULL,
  htgroupname varchar(32) NOT NULL,
  PRIMARY KEY  (htusername,htgroupname)
);

CREATE TABLE users (
  htusername varchar(32) NOT NULL,
  htpassword varchar(32) NOT NULL,
  PRIMARY KEY  (htusername)
);

BTW: don’t forget to enter data in the tables 😉

Posted in Comp | Getagged: , , | Leave a Comment »