ASF Home | KID Home | Search/Login | Help | Privacy | Fri Jul 4 13:54:03 2025 (Sydney/AU) | |
Australian Speleological Federation KID: Documentation: Apache mod_auth_mysql Module |
Overview
Building and Installing from Source
Problems that can Occur and their Solution
The KID uses mod_auth_mysql to link user web authentication directly to the sys_user table, specifically the username and groupname fields. The module mod_auth_mysql isn't a Perl module but a small C program. You can install this using a pre-compiled package from your Linux distribution or download the source code and compile it.
For Debian the package is libapache-mod-auth-mysql. Just install the package using apt-get
and return to the Installation Guide.
(RedHat package mod_auth_mysql-3.0.0-3.1.i386.rpm or similar version may be an equivalent.)
Use the remainder of this document as a guide if you intend to compile mod_auth_mysql from source instead of using a pre-compiled package. To compile from source you will require the gcc compiler, MySQL development files (for mysql.h), the zlib development files, and the Apache Development Kit.
Download mod_auth_mysql.tgz from: http://sourceforge.net/sourceforge/modauthmysql/. Before you can compile it you will need to install the other requirements mentioned above.
You will need the Apache webserver development kit as apxs is provided by this kit.
$ apt-cache search apxs apache-dev - Apache webserver development kit $
On a Debian machine install it like so:
$ sudo apt-get install apache-dev Reading Package Lists... Done Building Dependency Tree... Done The following extra packages will be installed: libdb2-dev libdb2-util libexpat1-dev The following NEW packages will be installed: apache-dev libdb2-dev libdb2-util libexpat1-dev 0 packages upgraded, 4 newly installed, 0 to remove and 14 not upgraded. Need to get 921kB of archives. After unpacking 2626kB will be used. Do you want to continue? [Y/n] y
You will also need mysql.h for the compilation.
(Otherwise you will get an error like this: 'mod_auth_mysql.c:269:19: error: mysql.h: No such file or directory'
when you try to compile the package.)
$ apt-cache search mysql | grep dev libmysqlclient10-dev - mysql database development files
$ apt-cache show libmysqlclient10-dev Package: libmysqlclient10-dev Version: 3.23.49-8 Replaces: libmysqlclient9-dev, libmysqlclient6, libmysqlclient6-dev, mysql-gpl-dev, mysql-dev, mysql-devel Provides: libmysqlclient-dev Depends: libmysqlclient10 (>= 3.23.49-8) Conflicts: libmysqlclient9-dev, libmysqlclient6-dev, mysql-gpl-dev, mysql-dev, mysql-devel Description: mysql database development files. This package includes development libraries and header files.
Note that there may be a later version than libmysqlclient10-dev such as libmysqlclient15-dev. Install whatever version is suitable.
$ apt-cache search zlib | grep dev libmng-dev - M-N-G library (Development headers) zlib1-altdev - compression library - development (for libc5) zlib1g-dev - compression library - development $
# apt-get install zlib1g-dev
Now try and compile mod_auth_mysql. There is a README and a BUILD file that comes with mod_auth_mysql that explains how to build and install it. This says:
For either Apache 1.x or Apache 2.x:
apxs -c -lmysqlclient -lm -lz mod_auth_mysql.c
mod_auth_mysql-3.0.0$ apxs -c -lmysqlclient -lm -lz mod_auth_mysql.c gcc -DLINUX=22 -DEAPI -DTARGET="apache" -DHAVE_SET_DUMPABLE -DDB_DBM_HSEARCH=1 -DDEV_RANDOM=/dev/random -DUSE_HSREGEX -O1 -g -Wall -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -fPIC -DSHARED_MODULE -I/usr/include/apache-1.3 -c mod_auth_mysql.c mod_auth_mysql.c:269:19: error: mysql.h: No such file or directory mod_auth_mysql.c:379: error: expected specifier-qualifier-list before 'MYSQL'
In the above attempt it still could not find the mysql.h header file so I added "-L/usr/lib/mysql -I/usr/include/mysql" to specify the location. This is covered in the documentation that accompanies the mod-auth-mysql source.
mod_auth_mysql-3.0.0$ apxs -c -L/usr/lib/mysql -I/usr/include/mysql -lmysqlclient -lm -lz mod_auth_mysql.c gcc -DLINUX=22 -DEAPI -DTARGET="apache" -DHAVE_SET_DUMPABLE -DDB_DBM_HSEARCH=1 -DDEV_RANDOM=/dev/random -DUSE_HSREGEX -O1 -g -Wall -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -fPIC -DSHARED_MODULE -I/usr/include/apache-1.3 -I/usr/include/mysql -c mod_auth_mysql.c gcc -shared -o mod_auth_mysql.so mod_auth_mysql.o -L/usr/lib/mysql -lmysqlclient -lm -lz mod_auth_mysql-3.0.0$
Now it compiles fine. A directory list will show that a new mod_auth_mysql.so has been built.
$ ls -l total 68 -rw-r--r-- 1 kid kid 8372 May 11 2003 README -rw-r--r-- 1 kid kid 26379 May 11 2003 mod_auth_mysql.c -rw-r--r-- 1 kid kid 8288 Nov 28 14:19 mod_auth_mysql.o -rwxr-xr-x 1 kid kid 13488 Nov 28 14:19 mod_auth_mysql.so
After building the module, you need to install it to your modules directory.
The README says that if you are using Apache 1.x install using: 'apxs -i mod_auth_mysql.so'
# apxs -i mod_auth_mysql.so cp mod_auth_mysql.so /usr/lib/apache/1.3/mod_auth_mysql.so chmod 755 /usr/lib/apache/1.3/mod_auth_mysql.so #
Next, add the following directive to httpd.conf:
LoadModule mysql_auth_module modules/mod_auth_mysql.so
Apache should restart OK.
# apachectl restart /usr/sbin/apachectl restart: httpd started #
# /usr/sbin/apache-modconf apache Error: mod_auth_mysql.so does not have a corresponding .info file. The above errors might cause apache to not work properly or start. Please refer to the documentation on how to fix it or report it to Debian Apache Mailing List if in doubt on how to proceed. #
Create a .info file like this:
/usr/lib/apache/1.3# cat 500mod_auth_mysql.info LoadModule: auth_mysql_module /usr/lib/apache/1.3/mod_auth_mysql.so Description: Authenticate via MySQL /usr/lib/apache/1.3#
You may get an error like this when you try to start Apache. It could be any one of the
directives in the
# apachectl start Syntax error on line 73 of /etc/apache/kiddev-httpd.conf: Invalid command 'AuthMySQLCryptedPasswords', perhaps mis-spelled or defined by a module not included in the server configuration /usr/sbin/apachectl start: httpd could not be started #
The reason for this is that over time and/or between different version of mod-auth-mysql the API has changed and you have the wrong directive in httpd.conf compared to what is in the module /usr/lib/apache/1.3/mod_auth_mysql.so. For instance here the directive "AuthMySQLCryptedPasswords On" is now replaced with "AuthMySQLPwPasswords crypt".
AuthMySQLCryptedPasswords On AuthMySQLHost AuthMySQLUser AuthMySQLUserTable AuthMySQLNameField AuthMySQLPasswordField
Other mod-auth-mysql packages require the directives to be these:
AuthMySQL_Encrypted_Passwords On AuthMySQL_Host AuthMySQL_User AuthMySQL_Password_Table AuthMySQL_UserName_Field AuthMySQL_Password_Field
How can you tell what to use? If building from source read the documentation for the package and the .c code or even strings the .so file. If using a Debian package read its documentation.
Note that mod_auth_mysql built OK on my PPC laptop but apache didn't want to start.
# apache start Syntax error on line 248 of /etc/apache/httpd.conf: Can't locate API module structure `auth_mysql_module' in file /usr/lib/apache/1.3/mod_auth_mysql.so: apache: undefined symbol: auth_mysql_module #
From Googling I found the answer:
Just change auth_mysql_module to mysql_auth_module and it will work. Here are the relevant, commented lines from httpd.conf.
# MRL changed the LoadModule line to get mod_auth_mysql.so to load. #LoadModule auth_mysql_module /usr/lib/apache/1.3/mod_auth_mysql.so LoadModule mysql_auth_module /usr/lib/apache/1.3/mod_auth_mysql.so
After making the above change apache then started.
Back to Top