MySQL-based Apache user authentication instance-Linux Enterprise Application-Linux server application information. The following is a detailed description. Apache version: 2.0.54
Required module: mod_auth_mysql
Above software: http://www.bruce.com.cn/software
Apache requires DSO compilation and installation. Assume that apache is installed in the/usr/local/apache directory, and mysql is installed in the/usr/local/mysql directory.
First download mod_auth_mysql: http://www.bruce.com.cn/software... _mysql-2.9.0.tar.gz
Edit the httpd. conf file.
[Root @ www mod_auth_mysql-2.9.0] # vi/usr/local/apache/conf/httpd. conf
Add the following lines to httpd. conf: (The following is an excerpt from my httpd. conf)
AuthType Basic
AuthMySQLHost localhost
AuthMySQLPort 3306
AuthMySQLDB database # database to be accessed
AuthMySQLUser mysql_user # user accessing the database
AuthMySQLPassword user_password # User Password
AuthMySQLPwEncryption md5 # MD5 Encryption
AuthMySQLEnable On
AuthMySQLUserTable user_table # data table to be accessed
AuthMySQLNameField username # username Field
AuthMySQLPasswordField password # password Field
AuthMySQLGroupTable user_table # Same as the user table
AuthMySQLGroupField mygroup # user group field
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, and 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:
AuthType Basic
AuthName "resource download is only available to Members"
Require valid-user
Restart apache again
[Root @ www mod_auth_mysql-2.9.0] # service httpd restart
After using this authentication method, your browsing records can be kept in Apache logs. You can view your views using awstats and other log statistics software, the Knowledge Flow inside the company can be clearly viewed.
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