.htaccess using MySQL problem

Discussion in 'HOWTO-Related Questions' started by ACDII, Jan 23, 2007.

  1. ACDII

    ACDII Member

    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.
  2. falko

    falko Super Moderator ISPConfig Developer

    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 [I]searchstring[/I]
    to search for the appropriate packages.
  3. ACDII

    ACDII Member

    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.
  4. ACDII

    ACDII Member

    AHA Fixed it!!

    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.
    Last edited: Jan 24, 2007
  5. falko

    falko Super Moderator ISPConfig Developer

    What do you mean with that? :confused:
  6. ACDII

    ACDII Member

    ISPConfig creates an httpd.conf file that includes the time and date it was last updated.

  7. martinfst

    martinfst ISPConfig Developer ISPConfig Developer

    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.
  8. ACDII

    ACDII Member

    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.
  9. martinfst

    martinfst ISPConfig Developer ISPConfig Developer

    What does the line in /etc/apache2/apache2.conf near the end say? It starts with:
    Include /etc/apache2/vhosts/............
  10. ACDII

    ACDII Member

    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.
  11. falko

    falko Super Moderator ISPConfig Developer

    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.

Share This Page