Quantcast
Channel: Hack Admin » apache
Viewing all articles
Browse latest Browse all 3

How to Implement htaccess with MySQL

$
0
0

Article by Aashish

# yum install httpd* mysql* -y

*** Install Module Needed for Authentication from MySQL databases. ***

# yum install mod_auth_mysql -y

*** Create a database which contains a table holding the username and passwd ***

#mysql -u root -p
password:

mysql> create database httpd;
mysql> use httpd;
mysql> create user ‘apache’@'localhost’ identified by ‘apache’;
mysql> create table users( user_name char(30) NOT NULL, user_passwd char(30), user_group char(30)
NOT NULL, PRIMARY KEY(user_name));
mysql> grant all privileges on *.* to ‘apache’@'localhost’ with GRANT option;
mysql> INSERT INTO users VALUES (’testuser’, ENCRYPT(’testpass’), ‘user’);
mysql> INSERT INTO users VALUES (’admin’, ENCRYPT(’testpass’), ‘group’);
mysql> quit

# service mysqld restart

# vim /etc/httpd/conf/httpd.conf


AuthName “MySQL group authenticated zone”
AuthType Basic
AuthMYSQLEnable on
AuthMySQLUser apache
AuthMySQLPassword apache
AuthMySQLDB httpd
AuthMySQLUserTable users
AuthMySQLNameField user_name
AuthMySQLPasswordField user_passwd
AuthMySQLGroupField user_group
require group admin /or/ require valid-user

# service httpd restart

enjoy


Viewing all articles
Browse latest Browse all 3

Trending Articles