MacDevCenter    
 Published on MacDevCenter (http://www.macdevcenter.com/)
 See this if you're having trouble printing code examples


Installing libapreq on Jaguar: An Update

by David Wheeler
02/07/2003

In part one of this series, I identified the lack of support for Mac OS X by the libapreq library (which includes the Apache::Request and Apache::Cookie Perl modules) as a reason to build your own Apache/mod_perl server. Although the other issues I identified with Apple's default Apache installation remain, the libapreq issue is no longer quite as relevant.

As of version 1.1, libapreq formally supports Mac OS X 10.2. This means that those of us running Jaguar can now use libapreq without compiling support for it directly into Apache. Mac OS X 10.1 users must still apply this workaround, and the patch is now included in the libapreq distribution itself (see INSTALL.MacOSX in the distribution for details). But Mac OS X 10.2 users are now free to use libapreq as it was intended, including with Apple's Apache installation, should the mood strike.

That said, installing libapreq on Jaguar is still a bit different than doing so on other platforms. Rather than the usual approach for installing Perl modules, the libapreq installation is a two-step process. So I thought it only fair to provide a quick update to guide you through the installation process. Note that if you're going to follow this procedure, you'll need to recompile Apache/mod_perl without the patch. Just follow the instructions in the article, only don't download and apply the libapreq patch. Once you've tested that Apache and mod_perl are working again, return here to install libapreq 1.1.

Installing libapreq

First, we'll need to download libapreq. The latest version can always be found on the libapreq home page. It's also available on CPAN, but don't use the Perl CPAN module to install it, because, as I said, libapreq requires a special installation process on Mac OS X, and the CPAN module doesn't know that.

% cd /usr/local/src
% curl -O http://www.apache.org/dist/httpd/libapreq/libapreq-1.1.tar.gz
% tar zxvf libapreq-1.1.tar.gz
% cd libapreq-1.1

Here I follow the familiar pattern of using curl to download the sources, and then tar to unpack them. Then I change into the new libapreq-1.1 directory. As I said, installing libapreq on Mac OS X is a two-step process; first we need to build and install the C library that the Perl modules rely on, and later we'll install the Perl modules themselves.

% ./configure --with-apache-includes=/usr/local/apache/include
% make
% sudo make install

The --with-apache-includes=/usr/local/apache/include option tells configure where to find the include files for our new Apache installation. Then make and make install, of course, compile and install the libapreq C library. If you wanted to use libapreq with Apple's Apache installation, you'd just need to change the configure command to point to the appropriate include directory, /usr/include/httpd, instead.

Next, we need to build the libapreq Perl modules. These follow the usual Perl module installation procedure:

% perl Makefile.PL
% make
% sudo make test
% sudo make install

Related Reading

The Unix CD Bookshelf
By O'Reilly Media, Inc.

The Makefile.PL script will ask a series of questions and then build the Makefile that will allow us to build the Perl modules. Be sure you enter the proper location for your new Apache server when prompted; Makefile.PL will most likely find Apple's Apache at /usr/sbin/httpd, and, unless you're installing libapreq to use with Apple's Apache, you'll need to enter /usr/local/apache/bin/httpd instead. On the other hand, if you are installing libapreq for use with Apple's Apache, you need to make sure that you use Apple's build of Perl. That usually means executing /usr/bin/perl5.6.0 Makefile.PL, since simply using perl will most likely use your shiny new Perl 5.8.0 installation.

Of course, make compiles the modules, while make test and make install test and install Apache::Request and Apache::Cookie. Be aware that make test will only work if you entered correct information when prompted by Makefile.PL and when the Perl modules LWP and URI have been installed from CPAN. The great thing about make test, in this case, is that it actually uses our Apache/mod_perl server to test the new Perl modules. This means that, if all of the tests passed, then Apache::Request and Apache::Cookie will be in complete working order and ready to use.

And that's all there is to it. Kudos to the libapreq development team for getting it working on Mac OS X. Now, get back to your Apache/mod_perl development work!

David Wheeler is a developer at Portland, Oregon-based Values of n, where he writes the code that makes Stikkit's little yellow notes think.


Return to the Mac DevCenter.


Copyright © 2009 O'Reilly Media, Inc.