|Your Daily Source for Apache News and Information|
|Breaking News||Preferences||Contribute||Triggers||Link Us||Search||About|
In my last article, I talked about using databases for authentication, and I introduced mod_auth_dbm as a possible way to do that.
This week, we'll look at MySQL, a very popular database server, and using mod_auth_mysql to use MySQL to store your authentication information.
MySQL is a wonderful database server, which is distributed under the GPL, and is available from http://www.mysql.com/ MySQL is lightweight and fast. It lacks some of the features of larger, more expensive database servers, such as stored procedures, triggers, and various other things, but it contains most of the functionality needed for most small to medium projects. And, it contains some cool stuff like a regular expression language that can be used in SQL statements.
Because MySQL is free, and because it is just such a great database, it is the favorite database in use by folks on *nix operating systems--particularly folks with small budgets. And it also runs on Windows.
You can get
The following are the configuration directives that you'll need to know about:
This directive tells where your server is running, and what username and password are necessary to get data from the database. This directive is only necessary if the server is running somewhere other than
If all of your authentication will be done against the same database, you'll probably want to set the following directive:
If you'll be authenticating different directories or files against different databases, you can leave this out, and set the database in the various directories.
The following directives can appear either in your
Note that you'll be using the usual directives to set up password protection on the directory:
AuthType Basic AuthName "Members Only" require group admin
There are several other directives, but these are the main ones that you will be using most of the time. The following is an example .htaccess file that works for me:
Auth_MySQL_Info localhost db_user db_password Auth_MySQL_DB authentication Auth_Mysql_Password_Table passwords
AuthType Basic AuthName "Members Only" require valid-user
The above assumes that the username is in a field
Once you have your
You can maintain your user and password lists via whatever database management tool you are used to using. There's no handy tool like
You can use Perl and DBI to talk to your database. In my next column, I'll be talking at greater length about using Perl to manage your password files. There are a plethora of ways to do this, so it really merits its own article.
Please let me know if there are other topics that you'd like for me to talk about in future columns. You can send your suggestions to me at And please let me know what you think of my columns, at that same address. Many thanks for reading down this far!
|About Triggers||Media Kit||Security||Triggers||Login|
All times are recorded in UTC.
Linux is a trademark of Linus Torvalds.
Powered by Linux 2.4, Apache 1.3, and PHP 4