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
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.
10:00 pm
Hi all!
For the steps I’m reading here I’m really bad because I think I’m getting different errors than the exposed here, on the apache compilation.
Some months ago I compiled and installed openssl 0.9.7m and compile apache 2.2.11 with that version installed but after recompiling php too, I continue seeing that the linked openssl version were 0.9.7l (bundled version).
When I installed the openssl I used the “–prefix=/usr” directive to overwrite the stock openssl and it worked apparently because when I use the “openssl version” command it shows me 0.9.7m version as installed.
Later I compiled a lot of 0.9.8 versions of openssl and when I tried to recompile apache 2.2.11 to link to those newer versions of openssl, I began to get the following error:
/sources/httpd-2.2.11/srclib/apr/libtool –silent –mode=link gcc -g -O2 -L/usr/local/lib -L/usr/lib -o ab ab.lo /sources/httpd-2.2.11/srclib/pcre/libpcre.la /sources/httpd-2.2.11/srclib/apr-util/libaprutil-1.la -lexpat -liconv /sources/httpd-2.2.11/srclib/apr/libapr-1.la -lpthread -lssl -lcrypto -lpthread
Undefined symbols:
“_BIO_set_callback_arg”, referenced from:
_start_connect in ab.o
“_BIO_get_callback_arg”, referenced from:
_ssl_print_cb in ab.o
“_SSL_CTX_set_info_callback”, referenced from:
_main in ab.o
“_BIO_set_callback”, referenced from:
_start_connect in ab.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
make[2]: *** [ab] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all-recursive] Error 1
I’m trying to follow the comments on this forum but I can’t get apache compiled.
I’m using the default Darwin layout because as I can see, is exact to the Leopard layout offered here so I’m most pretty sure that’s not the problem.
My complete openssl configuration command (same for all versions) is:
./configure darwin-i386-cc \
–prefix=/usr \
–with-zlib-lib=/usr/lib \
–with-zlib-include=/usr/include
The apache 2.2.11 configuration command is:
CC=”darwin-i386-cc”
./configure –enable-layout=Darwin \
–enable-mods-shared=all \
–with-ssl=/usr \
–with-mpm=prefork \
–disable-unique-id \
–enable-ssl \
–enable-dav \
–enable-cache \
–enable-proxy \
–enable-logio \
–enable-deflate \
–with-included-apr \
–enable-cgi \
–enable-cgid \
–enable-suexec
Thanks in advance to all!
7:13 am
@Daniel, I’m sorry I’m not aware of these issues with other libraries than the default installation of OpenSSL.
I don’t have the time or resources to investigate your issue at the moment. Perhaps other readers are willing to chip in.
By the way, this is not a forum. The forum is located here: http://diymacserver.com/forum/
3:11 pm
Thanks for your fast response Richard but what do you mean saying you aren’t aware about issues with other libraries than the default installation of OpenSSL??
I mean, I’m not making the default OpenSSL installation? Im not making the default Apache installation? Maybe that’s the problem as you say! Can you help me telling me which are the default installation of both software?
Thanks again!
3:16 pm
@Daniel, I only support compiling Apache on mac OS X with the settings described above. I cannot support people trying to compile other libraries (like OpenSSL) that are used by apache that might break dependencies. As is as you described in your case.