Database Journal
MS SQL Oracle DB2 Access MySQL PostgreSQL Sybase PHP SQL Etc SQL Scripts & Samples Tips Database Forum Rss Feed

» Database Journal Home
» Database Articles
» Database Tutorials
MS Access
SQL Scripts & Samples
» Database Forum
» Slideshows
Free Newsletters:

News Via RSS Feed

Rss Feed

Database Journal |DBA Support |SQLCourse |SQLCourse2

Featured Database Articles


Posted Jan 25, 2000

Setting Up a MySQL Based Website - Part II - Page 2

By DatabaseJournal.com Staff

by Andrew Chen

Setting up Mod_auth_mysql

For the purpose of this tutorial, we'll be working with a source distribution of Apache, under Slackware Linux 4.0. For RedHat users, there are RPMs with mod_auth_mysql already compiled in. (Newer versions of Slackware Linux have Apache with mod_auth_mysql already compiled in as well.)

In order to setup mySQL-based authentication under Apache, we need to recompile Apache, along with the mod_auth_mysql module. You can grab your own copy of Apache from http://www.apache.org/dist/. (You can also download a copy of mod_auth_mysql from the author's Web page at http://bourbon.netvision.net.il/mod_auth_mysql/).

After unpacking both archives, change to the unpacked mod_auth_mysql directory and run ./configure --with-apache=../apache_1.3.11. If this continues without incident, you should be all set to run make. This make should be quick, with instructions following. Change to your Apache directory and run ./configure --activate-module=src/modules/auth_mysql/libauth_mysql.a, followed by a make all install. After some puttering, if all went without incident, you should have your very own copy of Apache installed in /usr/local/Apache.

The next step is to configure Apache to query the mySQL database every time we request mySQL-based authentication. Inside /usr/local/Apache/conf, we'll create a file named mysql.conf. We'll keep our global configuration parameters inside here.

## mysql.conf - Configuration file for mod_auth_mysql 2.20 for
## Apache 1.3.x
## Andrew Chen - aznthinker@iname.com - http://www.linuxplanet.com/

# Configure the target authentication host with the mySQL server
# Syntax: Auth_MySQL_Info host user password
Auth_MySQL_Info localhost apache authenticate

# Specify which database to find the users table
# Syntax: Auth_MySQL_General_DB database
Auth_MySQL_General_DB apache

# Specify the tables for passwords and groups
# Syntax: Auth_MySQL_Password_Table table
Auth_MySQL_Password_Table members
Auth_MySQL_Group_Table members

# Specify the fields for username, password, and group
# Syntax: Auth_MySQL_Username_Field field
Auth_MySQL_Username_Field username
Auth_MySQL_Password_Field passwd
Auth_MySQL_Group_Field groups

# See more options at http://bourbon.netvision.net.il/mod_auth_mysql/

We need to tell Apache to load this extra configuration file at startup time by adding the following line to the end of httpd.conf:

Include mysql.conf .

At this point, feel free to start up Apache the way you typically do. For most source installations, the proper command is /usr/local/apache/bin/apachectl restart.

Page 3: Protecting a Directory

MySQL Archives

Latest Forum Threads
MySQL Forum
Topic By Replies Updated
MySQL in high availability and transction secure banking application klamor 1 August 28th, 10:24 AM
MySQL rollback UAL225 1 August 28th, 10:15 AM
Browsing a DB file that uses MySql finleytech 1 July 26th, 10:51 AM
php cookie won't pass variable to next page ITdevGirl 0 June 22nd, 12:13 PM