View Full Version : .htaccess using MySQL problem
ACDII
23rd January 2007, 23:19
I attempted to use Mod Auth MySQL Under Apache 2 and Debian, on my Fedora Core 4 ISPConfig server, and I cant get it to work, but I do have htpasswd working, so at least I know that part is working. How can I get it to use MySQL instead? I already have the database portion completed where I can add, remove users, change passwrods, etc, and want to utilize it for one of my sites, the other sites have their own type of authentications, but dont utilize CGI scripts, where this one site I have does, and I want to lock down access to the CGI portion more than anything, but dont want to have to go into the server to add or remove users.
I dont need groups for it, just want simple username and password authentication.
falko
24th January 2007, 14:18
You're referring to this tutorial? http://www.howtoforge.com/mod_auth_mysql_apache2_debian
Did you install all the required packages? I'm sure their names are different on Fedora, but you could use
yum search searchstring to search for the appropriate packages.
ACDII
24th January 2007, 17:59
I get not found when I try to apt get those files. I have php and mysql already installed, I used the howto fedora core 4 perfect install. I did a yum search apache and got a ton of stuff back, I assume this is stuff already installed.
I found mod_auth_mysql.i386 1:2.6.1-4 base
Matched from:
Basic authentication for the Apache web server using a MySQL database.
and also did an apt-get for it and it installed it, so I dont know by that if it was already installed or not, so I am totally confused on it now.
ACDII
24th January 2007, 19:50
OK, finally figured it out. Everything was already installed, but I needed to add something to the httpd.conf file. I run ISPconfig, so it doesnt use the standard httpd.conf, but one with a timestamp on it.
I added LoadModule mysql_auth_module modules/mod_auth_mysql.so to it, then the .htaccess file I put in the following.
AuthName "MySQL Testing"
AuthType Basic
AuthMySQLHost localhost
AuthMySQLDB auth
AuthMySQLUserTable user_info
AuthMySQLEnable On
AuthMySQLUser <'db_user'>
AuthMySQLPassword <'password'>
AuthMySQLNameField user_name
AuthMySQLPasswordField user_passwd
AuthMySQLPwEncryption none
AuthMySQLGroupTable user_info
AuthMySQLGroupField group
require valid-user
I setup a new table in the auth database
CREATE TABLE user_info (
user_name CHAR(30) NOT NULL,
user_passwd CHAR(20) NOT NULL,
user_group CHAR(10),
[ any other fields if needed ]
PRIMARY KEY (user_info)
)
I also added a email field for lost password feature, added a user and BOOM it worked. I need to tweak it for password encryption using SHA1. SO if anyone else is looking to do this on Fedora, I hope this helps.
falko
25th January 2007, 20:56
but one with a timestamp on it.
What do you mean with that? :confused:
ACDII
26th January 2007, 00:47
What do you mean with that? :confused:
ISPConfig creates an httpd.conf file that includes the time and date it was last updated.
httpd.conf.29-11-06_22-53-57
martinfst
26th January 2007, 10:21
That config file is not used. It uses the one without date_time. The one with date_time contains an error and is therefor marked as unusable by ISPConfig.
To see what's wrong, switch the config file without a date/time with the file with the latest timestamp, execute 'httpd -t' and fix the error.
ACDII
26th January 2007, 17:01
I disagree. I have only made changes to that file since I discovered that making changes to the httpd.conf file made no difference when I restart httpd. It was in that file that I inserted the LoadModule for mysql AUth, not the httpd file, and it worked. I also noticed that after adding a website to ispconfig, the httpd.conf file was untouched, the timestamp on it was still at the date when I first built the machine, but the file with the timestamp in it had the changes in it. I just compare the two files, httpd.conf does not have
LoadModule mysql_auth_module modules/mod_auth_mysql.so
in it, nor does it have
AuthMySQL_Info localhost auth_user
in it, which is what the .htaccess file uses to communicate with the mysql database. If what you say is true, then it would not be working, would it.
martinfst
26th January 2007, 17:05
What does the line in /etc/apache2/apache2.conf near the end say? It starts with:
Include /etc/apache2/vhosts/............
ACDII
26th January 2007, 17:50
What does the line in /etc/apache2/apache2.conf near the end say? It starts with:
Include /etc/apache2/vhosts/............
Fedora doesnt have it setup that way, it is /etc/httpd, so that may be why its different. The httpd.conf doesnt have include /etc/httpd/conf/vhosts/...., but the timestamped one does.
falko
26th January 2007, 18:51
ISPConfig creates an httpd.conf file that includes the time and date it was last updated.
httpd.conf.29-11-06_22-53-57
That's a backup of your old httpd.conf (made by ISPConfig's installer when it was last installed or updated) and isn't used anymore.
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.