October 30, 2014
 
 
RSSRSS feed

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

Performing User Authentication via MySQL

  • January 24, 2000
  • By Andrew Chen

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.

Sitemap | Contact Us