Multiple Apache httpd configurations - One Installation

From n0r1sk software solutions
Jump to: navigation, search


This is an extension to the http daemon from

The goal was to advance apache's http daemon that we can start it with multiple configurations on one single server with many ip addresses! We use the http daemon generally for loadbalancing Tomcat/IIS/... applications + SSL offloading.

On our former installations we had to compile the http daemon for every instance we wanted to run on the server. Now we can compile/install one apache http daemon and use this single instance with multiple configurations. (ip's/ssl-certificates/...)

The other goal was that it had to be easy to change the http daemon version to a newer one which is now pretty charming!  :)

Compiling / installing & configuring Apache's HTTPD + Modules

Installing & configuring the httpd

Create apache2 folder in /usr/local

Downloading the source to root/software

eventually set proxy environment variable

export http_proxy=http://IP:Port

Patching the sources

If your installation is not that big (# of access) you can skip the following step.

Set the compiler flag via the enironment varible:


Installing the needed libraries

apt-get install zlib1g-dev libssl-dev build-essentials

Extracting the downloaded source

tar -zxvf httpd-2.2.XX.tar.gz

Building & installing the package

After patching the sources (if necessary for you) it's time to configure / compile & install apache's http daemon.

make clean

Change to the extracted httpd-2.2.XX directory.

./configure --enable-mods-shared=all --enable-modules=all --enable-proxy --enable-proxy-connect --enable-proxy-ftp \
 --enable-proxy-http --enable-proxy-balancer --enable-ssl=shared --with-mpm=worker --prefix=/usr/local/apache2/2.2.XX \

make install

Creating symlink

Creating the "core"-link (symlink) in the /usr/local/apache2/ folder to 2.2.XX

ln –s 2.2.XX core

Installing & configuring mod_jk (Tomcat Connector)

Downloading the source to root/software


Extracting the downloaded source

tar -zxvf tomcat-connectors-1.2.XX.tar.gz

Building & installing the package

cd tomcat-connectors-1.2.XX-src/native
make clean

Change to the "native"-folder

./configure --with-apxs=/usr/local/apache2/core/bin/apxs
make install

Installing & configuring mod_perl

This module is needed for mod_macro!

Downloading the source to root/software


Installing the needed libperl library

apt-get install libperl-dev

Extracting the downloaded source

tar -zxvf mod_perl-2.0-current.tar.gz

Building & installing the package

cd mod_perl-2.0.X

perl Makefile.PL MP_APXS=/usr/local/apache2/core/bin/apxs


The module was build under ./src/modules/perl/ in the build directory.

cp ./src/modules/perl/ /usr/local/apache2/core/modules/

Installing & configuring mod_macro

mod_macro is a great configuration enhancement for apache's http daemon. We use it to make our configurations easier to read & change!

Downloading the source to root/software


Extracting the downloaded source

The source has to be extracted to the source directory of the apache!

tar –zxvf mod_macro-1.1.XX
cp -Rp mod_macro-1.1.XX httpd-2.2.XX

Building & installing the package

cd /root/software/httpd-2.2.XX

/usr/local/apache2/core/bin/apxs -c mod_macro-1.1.XX/mod_macro.c

Installing the build module

cp ./mod_macro-1.1.11/.libs/ /usr/local/apache2/core/modules/

Template extension

Includes + + template. The & is available as download in the specific sections. Thx to where most of our scripts are hosted!  :)


Description of "" parameters [ options ] <commands...>

      -help|?         print help
      -ip|ipaddress   IP address
      -port           Port
      -folder|path    Folder name
      -delete|remove  Folder name
      -apache         init-script prefix
      -force          Force installation -ip IPADDRESS -port PORT -folder FOLDERNAME -apache APACHEFOLDER -delete FOLDERNAME -force yes/y

Description of "" parameters

int replace (InputFile, OutputFile, search-String, replace-String);

1.) Input file will be copied to /tmp/$file. $file will be extracted from input file (ex: inputfile: /usr/local/apache2/folderXY/conf/httpd.conf -> $file = httpd.conf)

2.) Search string will be searched and written to the output file

3.) /tmp/$file will be deleted

4.) Returned value = how often the search string was found (& replaced)

Description of "" script with "" function

1.) The whole template folder will be copied to $prefix/$folder (ex: /usr/local/apache2/folderXY)

2.) The following values will be replaced in httpd.conf (IP, Port, SSLPort, Folder, Prefix)

3.) The httpd start/stop script will be renamed from "template" to $folder (in /bin)

4.) The value XXConfig will be replaced by $folder

5.) Init-Script for the new httpd will be linked (ln -s /usr/local/apache2/$folder/bin/$folder /etc/init.d/apache2_$folder)

6.) Create runlevel entries (update-rc.d apache2_$folder defaults)

Modified httpd.conf in our template

1.) The mod_jk-module was linked

LoadModule jk_module modules/

2.) Some more configurations

MaxKeepAliveRequests 100
KeepAliveTimeout 5


<IfDefine !HIGHMEM>
<IfModule worker.c>
        ServerLimit 25
        StartServers 10
        MaxClients 1600
        ThreadLimit 64
        MinSpareThreads 25
        MaxSpareThreads 256
        ThreadsPerChild 64
        MaxRequestsPerChild 0

<IfDefine HIGHMEM>
<IfModule worker.c>
        ServerLimit 25
        StartServers 10
        MaxClients 3200
        ThreadLimit 128
        MinSpareThreads 25
        MaxSpareThreads 256
        ThreadsPerChild 128
        MaxRequestsPerChild 0

Options -Indexes

Include conf/sites-enabled/*

3.) Folders where created/linked under /conf ("sites-enabled" & "sites-available")

4.) The mod_perl-module was linked

LoadModule perl_module modules/
<IfModule !mod_perl.c>
Error Hey, you forgot to install mod_perl! I need it!

5.) The mod_macro-module was linked

LoadModule macro_module modules/

Multi-Apache Downloads

This download includes the "", "" and the corresponding template directory structure + configuration files/scripts!



Many thanks to the developers of the Apache http server as well as the modules mod_jk, mod_perl & mod_macro!
Here are some nice links!

Apache HTTP Server
Module mod_jk
Module mod_perl
Module mod_macro

last edit 16.03.2012 by Bernhard