Note: There are more recent instructions on compiling Apache on Leopard in the documentation set: Installing Apache
As people are compiling Apache on Leopard and because its not the usual configure, make, install procedure. I thought a separate blog post explaining it would help people to get it all working.
There are 2 ways to define the setup, go for the default Leopard install method and overwrite the current Apache installation or install a separate instance. The separate instance falls in line with all the other DIYMacserver documentation. The Leopard install will keep the functionality of the preference pane intact. You choose !
The difference in the configuration is made in the ‘config.layout’ file which determines where all the packages should be installed. For both methods copy the layout below and add it to the ‘config.layout’ file.
DIYMacserver installation configuration
prefix: /usr/local/apache2
exec_prefix: ${prefix}
bindir: ${exec_prefix}/bin
sbindir: ${exec_prefix}/bin
libdir: ${exec_prefix}/lib
libexecdir: ${exec_prefix}/modules
mandir: ${prefix}/man
sysconfdir: /etc/httpd
datadir: /Library/Webserver
installbuilddir: ${datadir}/build
errordir: ${datadir}/error
iconsdir: ${datadir}/icons
htdocsdir: ${datadir}/Documents
manualdir: ${datadir}/manual
cgidir: ${datadir}/CGI-Executables
includedir: ${prefix}/include
localstatedir: /var
runtimedir: ${localstatedir}/run
logfiledir: ${localstatedir}/log/httpd
proxycachedir: ${runtimedir}/proxy
</Layout>
Leopard installation configuration
prefix: /usr
exec_prefix: ${prefix}
bindir: ${exec_prefix}/bin
sbindir: ${exec_prefix}/sbin
libdir: ${exec_prefix}/lib
libexecdir: ${exec_prefix}/libexec+
mandir: ${prefix}/share/man
sysconfdir: /etc+
datadir: /Library/Webserver
installbuilddir: ${prefix}/share/httpd/build
errordir: ${prefix}/share/httpd/error
iconsdir: ${prefix}/share/httpd/icons
htdocsdir: ${datadir}/Documents
manualdir: ${datadir}/share/httpd/manual
cgidir: ${datadir}/CGI-Executables
includedir: ${prefix}/include+
localstatedir: /var
runtimedir: ${localstatedir}/run
logfiledir: ${localstatedir}/log+
proxycachedir: ${runtimedir}/proxy
</Layout>
If you’ve edited the ‘config.layout’ file you are ready to run the configuration script. Change the ‘–enable-layout’ to reflect your choice in configuration. So fill in either DIYMacServer or Leopard to choose, the example uses DIYMacServer as the layout.
--enable-mods-shared=all \
--with-ssl=/usr \
--with-mpm=prefork \
--disable-static \
--disable-unique-id \
--disable-ipv6 \
--enable-ssl \
--enable-dav \
--enable-cache \
--enable-proxy \
--enable-shared \
--enable-logio \
--enable-deflate \
--with-included-apr \
--enable-cgi \
--enable-cgid \
--enable-suexec
You can now run:
and if it all goes well:
If you run into errors or some strange thig happens which you can’t explain, please post you questions and the error into the forum on this site:
The configuration and all the other posts related to apache in the documentation set are still valid, you still can use those.



12:44 pm
well - it compiles and installs; but have you tried firing it up with mod_ssl enabled ?
It won’t here:
Cannot load /usr/libexec/apache2/mod_ssl.so into server: Symbol not found: _ssl_cmd_SSLCACertificateFile\n Referenced from: /usr/libexec/apache2/mod_ssl.so\n Expected in: flat namespace\n
otool -L mod_ssl.so
mod_ssl.so:
/usr/lib/libssl.0.9.7.dylib (compatibility version 0.9.7, current version 0.9.7)
/usr/lib/libcrypto.0.9.7.dylib (compatibility version 0.9.7, current version 0.9.7)
/usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 1.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 111.0.0)
http://trac.macports.org/projects/macports/ticket/13182
1:05 pm
Thanks for mentioning this, I compiled and tested a basic steup. Try some sites that I have installed on my test machine. It would be an enormous task to test all modules.
I will have a look into this and see what I can come up with although you mention that others are looking into this as well.
8:20 am
Thanks so much for this post! It saved me! I upgraded Leopard’s PHP 5.2.4 to 5.2.5 in order to compile some of the modules I needed, and I somehow hosed up Leopard’s Apache. After following your steps (without SSL), I’m up and running and the newest version of PHP is working, too!
10:30 pm
Hey - simply searched my system for previous versions of mod_ssl.so - found one in /usr/libexec/apache2/….
cd /usr/local/apache2/modules/
sudo mv mod_ssl.so mod_ssl.so.old
sudo ln -s /usr/libexec/apache2/mod_ssl.so mod_ssl.so
All is well in the world…
At least it is a quick workaround…
8:02 am
Thanks for confirming this, I’ve been breaking my head on this one and this option was something I wanted to try when everything else failed. Which it kind of has…
9:40 am
When i try to use the leopard layout i get following error
checking for APR… reconfig
configuring package in srclib/apr now
configure: error: expected an absolute directory name for –bindir: NONE/bin
configure failed for srclib/apr
10:20 am
Please check your config.layout file for rogue characters. Copy and paste actions sometimes translate HTML characters to ASCII values.
Don’t forget to do a ‘make clean’ between attempts…
8:17 pm
I install latest Apache 2.2.6 over the version that comes with Leopard. Have trouble with mod_ssl.so and wanted to find the original.. where can I download it.. I am new with the MAC in general so need some help.. THanks
8:38 pm
To find the original mod_ssl and how to use it with your newly compiled apache please read http://diymacserver.com/2008/01/13/leopard-apache-and-mod_ssl/
10:03 pm
After running the configure command with a DIYMacServer layout on httpd-2.2.8 the “#define APR_HAS_SENDFILE 1″ line was already set to 0. For what it’s worth.
3:04 pm
Thanks for the reminder, this error was only in 2.2.6
8:20 pm
Question… anyone know of an easy way to replace the default Leopard Apache 2 install with an Apache 1 install?
9:40 pm
Just compile it into the same location is my guess. The other question is off course why use 1 ?
9:30 pm
Everything worked great but…when I go to a shell and type in apachectl start I get:
httpd: Syntax error on line 114 of /etc/apache2/httpd.conf: Cannot load /usr/local/php5/libphp5.so into server: dlopen(/usr/local/php5/libphp5.so, 10): Symbol not found: _xmlTextReaderSchemaValidate\n Referenced from: /usr/local/php5/libphp5.so\n Expected in: /usr/lib/libxml2.2.dylib\n
The funny thing is that if I start up web sharing in preferences everything runs fine.
9:43 pm
You are confusing 2 different Apache installations with each other.
To start and stop the newly installed version you need to use /usr/local/apache2/bin/apachectl (with full path or you’ll use the default one)
To configure the new apache installation you’ll need to edit /etc/httpd/httpd.conf
7:33 pm
Hi I have a little question about installation apache on leopard.
Because I installed apache couple of days ago using your article - this and http://diymacserver.com/installing-apache/compiling-apache/
But I forgot about modrewrite module, and today I’m trying to re-compile apache.
But it return an error.
Configuring Apache Portable Runtime library …
checking for APR… reconfig
configuring package in srclib/apr now
configure: error: expected an absolute directory name for –bindir: NONE/bin
configure failed for srclib/apr
As I remember in first compilation I change
#define APR_HAS_SENDFILE @sendfile@ to 1 or 0 I don’t remember. In {apache_folder}/srclib/apr/include/arch
But now it doesn’t work :/
I’m confused, really don’t know what I’m doing wrong :/
If you have a time I will be glad for your help.
8:53 pm
The error is solved in the latest release of apache.
8:38 pm
[...] J’ai été inspiré par l’article : http://drewish.com/node/110 et http://diymacserver.com/2007/11/17/compiling-apache-on-leopard/ [...]
7:42 pm
Just faced this problem on the latest version (2.2.11) and fixed it without replacing with the old binary with the following steps:
1-) run the “make” command.
2-) “rm modules/ssl/*.la”
3-) run the “make” command again.
4-) note that a single “libtool” command line will be printed. copy the whole (big) line.
5-) cd modules/ssl
6-) paste the copied line and remove the “-export-symbols-regex” on the end of it. ENTER
This will create a working version of mod_ssl.so under the “.libs” folder and the “make install” command will install the working version.
Cheers!
7:47 pm
The latest Mac OS X update 10.5.7 also updated the OpenSSL installation and now it looks like the mod_ssl is working again. All you need to do is recompile Apache and all will be working as expected.