n42 Designs

Custom Web Development

Compiling Mod_perl for Apache 2.4 on OS X 10.10 Yosemite

| Comments

TL;DR: You can run this handy script to compile mod_perl for your system.


OS X 10.10 Yosemite upgrades the default Apache install from 2.2 in Mavericks to 2.4. In general, this is a good thing, but if you were using mod_perl, perhaps for mod_cfml with Railo for example, then mod_perl will no longer work.

Recently, there have been several commits so mod_perl will now support Apache 2.4. Since there are no binary releases yet, we will have to compile it ourselves.

I have managed to do this with help from this StackOverflow post.

First you need the latest source from the Apache SVN repositories. They mirror it on git, but its missing some dependencies, so I found it easier to use SVN.

svn checkout https://svn.apache.org/repos/asf/perl/modperl/trunk/ mod_perl-2.0

Then switch into the new directory:

cd mod_perl-2.0

Next, we need to be sure we have XCode 6.1 installed and the command line tools installed as well:

xcode-select --install

Once, we have that, we need to tell the compiler where to find a few dependencies. You can find the reasoning behind this in the StackOverflow post mentioned above, but in general you run:

1
2
3
/usr/bin/apr-1-config --includedir /usr/include/apr-1
sudo ln -s /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include/apache2 /usr/include/apache2
sudo ln -s /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include/apr-1 /usr/include/apr-1

This will create a couple simlinks and tell the compiler where some Apache headers are located.

Almost done. Next, we compile it. We need to set a compiler option to tell it to build using the gnu89 standard, instead of clang’s default C99. (Thanks to this blog post for that little nugget!)

perl Makefile.PL MP_CCOPTS=-std=gnu89 ; make ; sudo make install

This will install mod_perl.so to /usr/libexec/mod_perl.so

Lastly, we need to tell Apache to load the newly compiled module and restart apache. Add this line to your /etc/apache2/httpd.conf file:

LoadModule perl_module libexec/apache2/mod_perl.so

Then restart apache:

1
2
sudo apachectl configtest
sudo apachectl restart

If all is well, you should have a working mod_perl module inside Apache 2.4.

Comments