By using this website, you agree to the use of cookies as described in our Privacy Policy.

apache_auth_mysql

Apache Authentisierung mit MySQL

überall die dämlichen .htaccess Dateien zu verteilen war mir lästig. Viel hübscher ist es, die Authentisierung mit einer eleganten mySQL Tabelle zu machen.

Installation

apt-get install libapache2-mod-auth-mysql
cd /etc/apache2/mods-enabled/
ln -s /etc/apache2/mods-available/auth_mysql.load .

Datenbank anlegen

mysql -uroot -p  

mysql> grant all on apache2.* to auth_user@localhost identified by ‘<password>’;

mysql> flush privileges;

mysql> create database apache2;

mysql> use apache2;

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) );

INSERT INTO clients VALUES (‘meinBuntzer’, ‘besondersGeheim’, ‘meineGruppe’);

Apache-Config

  • /etc/apache2/apache.conf
Auth_MySQL_Info localhost <auth_user> <password>
  • /etc/apache2/sites-available/default
<Directory “<web directory>”>
Options +Indexes FollowSymLinks MultiViews
AllowOverride AuthConfig Options FileInfo Limit
Order allow,deny
Allow from all
</Directory>  

<location />
AuthMYSQL on
AuthMySQL_Authoritative on
AuthMySQL_DB apache2
AuthMySQL_Password_Table clients
AuthMySQL_Group_Table clients
AuthMySQL_Empty_Passwords off
AuthMySQL_Encryption_Types Plaintext Crypt_DES

AuthName “Mein Hausserver”
AuthType Basic
AuthBasicAuthoritative Off
AuthUserFile  /dev/null
require group <meineGruppe>
</location>
  • Zugriffe: 266

Related Articles