<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Nils Preusker &#187; MySQL</title>
	<atom:link href="http://www.nilspreusker.de/tag/mysql/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.nilspreusker.de</link>
	<description>Pragmatic Technologist</description>
	<lastBuildDate>Tue, 23 Mar 2010 10:44:19 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Compiling and Installing mod_auth_mysql on OS X 10.5.6</title>
		<link>http://www.nilspreusker.de/2009/04/17/compiling-and-installing-mod_auth_mysql-on-os-x-1056/</link>
		<comments>http://www.nilspreusker.de/2009/04/17/compiling-and-installing-mod_auth_mysql-on-os-x-1056/#comments</comments>
		<pubDate>Fri, 17 Apr 2009 17:43:57 +0000</pubDate>
		<dc:creator>nils</dc:creator>
				<category><![CDATA[OS X]]></category>
		<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://www.nilspreusker.de/?p=232</guid>
		<description><![CDATA[The apche module mod_auth_mysql makes it possible to use a MySQL database instead of e.g. a passwd file. There is an installer of the module for Mac OS X 10.4, but no installation package or port for Mac OS X 10.5 or later. I played around with the sources a little bit and finally managed [...]]]></description>
			<content:encoded><![CDATA[<p>The apche module mod_auth_mysql makes it possible to use a MySQL database instead of e.g. a passwd file. There is an installer of the module for Mac OS X 10.4, but no installation package or port for Mac OS X 10.5 or later. I played around with the sources a little bit and finally managed to get it to compile and apache to start without error messages. I&#8217;ve created a diff file to patch mod_auth_mysql.c. The following steps explain how to apply the patch, compile the module and test your apache configuration.</p>
<p>We&#8217;ll first create a src folder in your user directory, download mod_auth_mysql and expand it:</p>
<pre>$ mkdir ~/src
$ cd ~/src
$ curl -O http://puzzle.dl.sourceforge.net/sourceforge/\
modauthmysql/mod_auth_mysql-3.0.0.tar.gz
$ tar zxvf mod_auth_mysql-3.0.0.tar.gz</pre>
<p>Now you have the sources of the module in the folder mod_auth_mysql-3.0.0. Before we can compile it, the patch has to be applied. Here is the diff file <a href="http://www.nilspreusker.de/wp-content/uploads/2009/04/mod_auth_mysql.diff">mod_auth_mysql</a>, save it to</p>
<pre>~/src/mod_auth_mysql-3.0.0/mod_auth_mysql.diff</pre>
<p>To apply the patch, we change to the sources directory and execute the unix patch program that takes the original file and applies the diff file as patch:</p>
<pre>$ cd mod_auth_mysql-3.0.0
$ patch mod_auth_mysql.c mod_auth_mysql.diff</pre>
<p>Now we are ready to compile the module, install it and add it to http.conf, the apache configuration file. Apache modules are compiled using apxs, the <a title="apxs" href="http://httpd.apache.org/docs/2.2/programs/apxs.html" target="_blank">APache eXtenSion tool</a>. Before we start, lets look at the command:<a title="apxs" href="http://httpd.apache.org/docs/2.2/programs/apxs.html" target="_blank"><br />
</a></p>
<pre>$ sudo apxs -c -i -a -D lmysqlclient -lm -lz \
-I/usr/local/mysql/include/mysql/\
-L/usr/local/mysql/lib/ -Wc,"-arch x86_64" \
-Wl,"-arch x86_64" mod_auth_mysql.c</pre>
<p>We should execute apxs as super user because it will attempt to install the module to /usr/libexec/apache2/, so we prepend the command with sudo. the -c option tells apxs to compile the module, -i to install it and -a to add a line to http.conf, telling apache to load the module. The -I and -L options are used to provide information about where MySQL is installed and where to find the mysql.h file. I compiled and installed MySQL from source and installed it in the /usr/local/mysql/ directory, if your installation is in a different place, you might have to adjust these parameters. (An excellent guide on compiling and installing MySQL on OS X is available at http://hivelogic.com: &#8220;<a title="Installing MySQL on Mac OS X" href="http://hivelogic.com/articles/view/installing-mysql-on-mac-os-x" target="_blank">Installing MySQL on Mac OS X</a>&#8220;)</p>
<p>When you execute the above command, you should see an output like this:</p>
<pre>/usr/share/apr-1/build-1/libtool --silent --mode=compile gcc    -DDARWIN -DSIGPROCMASK_SETS_THREAD_MASK -no-cpp-precomp  -I/usr/include/apache2  -I/usr/include/apr-1   -I/usr/include/apr-1  -arch x86_64 -I/usr/local/mysql/include/mysql/ -Dlmysqlclient  -c -o mod_auth_mysql.lo mod_auth_mysql.c &amp;&amp; touch mod_auth_mysql.slo
/usr/share/apr-1/build-1/libtool --silent --mode=link gcc -o mod_auth_mysql.la -arch x86_64  -L/usr/local/mysql/lib/ -lm -lz -rpath /usr/libexec/apache2 -module -avoid-version    mod_auth_mysql.lo
/usr/share/httpd/build/instdso.sh SH_LIBTOOL='/usr/share/apr-1/build-1/libtool' mod_auth_mysql.la /usr/libexec/apache2
/usr/share/apr-1/build-1/libtool --mode=install cp mod_auth_mysql.la /usr/libexec/apache2/
cp .libs/mod_auth_mysql.so /usr/libexec/apache2/mod_auth_mysql.so
cp .libs/mod_auth_mysql.lai /usr/libexec/apache2/mod_auth_mysql.la
cp .libs/mod_auth_mysql.a /usr/libexec/apache2/mod_auth_mysql.a
ranlib /usr/libexec/apache2/mod_auth_mysql.a
chmod 644 /usr/libexec/apache2/mod_auth_mysql.a
----------------------------------------------------------------------
Libraries have been installed in:
   /usr/libexec/apache2

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
   - add LIBDIR to the `DYLD_LIBRARY_PATH' environment variable
     during execution

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------
chmod 755 /usr/libexec/apache2/mod_auth_mysql.so
[activating module `mysql_auth' in /private/etc/apache2/httpd.conf]</pre>
<p>If there are no error messages, you can test the apache configuration with apachectl:</p>
<pre>$ apachectl configtest</pre>
<p>If the output is</p>
<pre>Syntax OK</pre>
<p>you can continue by restarting apache:</p>
<pre>$ sudo apachectl graceful</pre>
<p>The next step would be to set up your locations in http.conf, but that&#8217;s for another time&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nilspreusker.de/2009/04/17/compiling-and-installing-mod_auth_mysql-on-os-x-1056/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>
