Install the MySQL user authentication module for apache2.x

Source: Internet
Author: User
Tags crypt sha1

Mod_auth_mysql has several versions, and the documentation is almost incomplete. The program downloaded in this article is from sourceforge.net (sf.net)

Http://modauthmysql.sourceforge.net/

The current version is 2.9.0. After downloading the file, create the directory mod_auth_mysql and decompress it. (Do not decompress the package directly under/usr/local/src). Follow the instructions in the build file to install the package as follows:

Apxs-C-lmysqlclient-lm-LZ mod_auth_mysql.c
Apxs-I mod_auth_mysql.la

Then add the following line to httpd. conf.
Loadmodule mysql_auth_module modules/mod_auth_mysql.so

In fact, compilation and installation are not difficult. configuration is a big challenge, especially the combination of existing user tables. The User table of my plog database is plog_users. The configuration I set is as follows:

<Ifmodule mod_auth_mysql.c>
<Location/>
Authtype basic

# Host address used to connect to the database. Generally, it is a local host.
Authmysqlhost localhost
Authmysqlport NNNN
# Database Name
Authmysqldb plog
# Database connection users?
Authmysqluser plogdb_user
# Database connection password
Authmysqlpassword Password
# None: Not encrypted (plain text)
# Crypt: Unix crypt () Encryption
# Scrambled: MySQL password encryption
# MD5: MD5 hashing
# AES: Advanced Encryption Standard (AES) Encryption
# Sha1: Secure Hash algorihm (sha1 )'
Authmysqlpwencryption MD5
Authmysqlenable on
Authmysqlusertable plog_users
Authmysqlnamefield user
Authmysqlpasswordfield Password
Authmysqlgrouptable plog_users
Authmysqlgroupfield user_group
</Location>
</Ifmodule>

As you can see from the above configuration, this module does not have special requirements for the user table, as long as the user name and the corresponding password can be found, if you need to verify a group, the group column is required.

All users in the company have the same Group. Therefore, group users are generally used for verification. Therefore, you must add the column user_group in the plog_user table, update the user_group column of all rows to a fixed value, for example, mygroup.

Here, grouptable and usertable are the same table. If you want a user to belong to multiple groups, you must create another group table.

After completing the preceding steps, add the. htaccess file to the directory to be encrypted as follows:

Authname "Please log in with the password and password for managing the blog"
Authtype basic
Require group mygroup

Such a plug-in verification system has been deployed, which is very effective for user table integration of multiple different applications in e-commerce applications. There are not many modified codes.

To modify the user password, you can use PHP's login $ _ server ["php_auth_user"] to determine the user name and then make corresponding judgments.

After using this authentication method, your browsing history can be kept in Apache logs. You can view your views using AWStats and other log statistics software.

ZZ: http://blog.csdn.net/techmylife/archive/2006/04/29/697548.aspx

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.