Compiling Apache web server with dynamic module support

Julius picture Julius · Mar 10, 2011 · Viewed 13.9k times · Source

I have just compiled Apache 2.2.17 on a fresh install of Ubuntu 10.04.2. It's a learning exercise to discover what actually goes on when you compile something rather than just using apt-get hence the avoidance of using apt-get in favour of compiling the thing myself.

I ran:

sudo ./configure --prefix=/etc/apache --enable-module=so --enable-rule=SHARED_CORE --enable-shared=max --enable-ssl=shared --enable-rewrite=shared

followed by the obligatory:

sudo make && sudo make install

All seemed to go well (Apache starts up no problems) except that in the Apache modules directory where I would have expected to see mod_rewrite.so and mod_ssl.so, instead I see:

#cd /etc/apache/modules
#ls -l
mod_rewrite.a
mod_rewrite.la
mod_ssl.a
mod_ssl.la

How can I turn these into .so files so I can link them with LoadModule in the Apache config?

Thanks in advance.

Answer

Lekensteyn picture Lekensteyn · Mar 10, 2011

You should not run everything as root. ./configure and make will work fine without root permissions, make install requires root permissions for writing to directories like /etc and /usr/bin.

/etc is not suitable for executables, let alone a full Apache installation. If you want to put your configuration files in /etc/apache, use the --sysconfdir=/etc/apache. The correct place to install a custom-build Apache is /usr/local.

To enable shared modules, you have to pass the --enable-so option, the modules which should be compiled as shared should be added to --enable-mods-shared.

The correct configure line for Apache + mod_ssl (shared module) + mod_rewrite (shared module) is, installed in /usr/local/apache with configuration files in /etc/apache:

./configure --prefix=/usr/local/apache --sysconfdir=/etc/apache --enable-so \
  --enable-rewrite --enable-ssl --enable-mods-shared='rewrite ssl'

After successful configuring Apache HTTPd, run make followed by sudo make install.

More information about the configure options can be found at the Apache HTTPd documentation.