Compling Apache 2.4 on Ubuntu or Debian

wget http://httpd.apache.org/dev/dist/httpd-2.4.2.tar.gz
wget http://httpd.apache.org/dev/dist/httpd-2.4.2-deps.tar.gz
tar xvfz httpd-2.4.2.tar.gz
tar xvfz httpd-2.4.2-deps.tar.gz
cd httpd-2.4.2/srclib
wget http://mirror.netcologne.de/apache.org//apr/apr-iconv-1.2.1.tar.gz
tar xvfz apr-iconv-1.2.1.tar.gz
mv apr-iconv-1.2.1 apr-iconv
wget http://zlib.net/zlib-1.2.6.tar.gz
tar xvfz zlib-1.2.7.tar.gz
mv zlib-1.2.7 zlib
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.21.tar.gz
tar xvfz pcre-8.21.tar.gz
mv pcre-8.21 pcre
wget http://www.openssl.org/source/http://openssl.org/source/openssl-1.0.1.tar.gz
tar xfz openssl-1.0.1.tar.gz
cd openssl-*
./config --prefix=/usr zlib-dynamic --openssldir=/etc/ssl shared
make
make test
sudo make install
cd ../..
./buildconf
./configure --prefix=/opt/apache2 --enable-pie --enable-mods-shared=all --enable-so --disable-include --enable-deflate --enable-headers --enable-expires --enable-ssl=shared --enable-mpms-shared=all --with-mpm=event --enable-rewrite --with-z=/home/mario/apache24/httpd-2.4.2/srclib/zlib --enable-module=ssl --enable-fcgid --with-included-apr
make 
sudo make install
cd ..
wget http://www.trieuvan.com/apache//httpd/mod_fcgid/mod_fcgid-2.3.7.tar.gz
tar xvfz mod_fcgid-2.3.7.tar.gz
cd mod_fcgid-*
APXS=/opt/apache2/bin/apxs ./configure.apxs
make
sudo make install

For using PHP install php-cgi

add httpd.conf

FcgidMaxProcesses 50
FcgidFixPathinfo 1
FcgidProcessLifeTime 0
FcgidTimeScore 3
FcgidZombieScanInterval 20
FcgidMaxRequestsPerProcess 0
FcgidMaxRequestLen 33554432
FcgidIOTimeout 120

in each vhost

Options Indexes ExecCGI
AddHandler fcgid-script .php
FCGIWrapper /usr/lib/cgi-bin/php5 .php

16 thoughts on “Compling Apache 2.4 on Ubuntu or Debian

  1. I wish I found this earlier. I spent the WHOLE day dealing with upgrading to 2.4.2 and then having to recompile PHP5.4.4 AND OpenSSL for the sake of PCI Compliance.

  2. It is not working for me. I tried it on Debian Squeeze. Some of the files are missing too.

    Is there anyone with success on Debian Squeeze, please share your work with me.

  3. Thanks for these steps. I used this successfully with the following changes to compile Apache 2.4.3 on Ubuntu 11

    a) The wget links were changed to get the latest version and mirrors closer to me
    b) I needed to install lib-pcre-dev prior to configuring apache
    c) I needed to set in ab.c a define statement at the top of the file as follows: #define OPENSSL_NO_SSL2

  4. For using PHP install php-cgi

    add httpd.conf

    FcgidMaxProcesses 50
    FcgidFixPathinfo 1
    FcgidProcessLifeTime 0
    FcgidTimeScore 3
    FcgidZombieScanInterval 20
    FcgidMaxRequestsPerProcess 0
    FcgidMaxRequestLen 33554432
    FcgidIOTimeout 120

    in each vhost

    Options Indexes ExecCGI
    AddHandler fcgid-script .php
    FCGIWrapper /usr/lib/cgi-bin/php5 .php

  5. Hello,
    to install apache 2.4.3 on debian Lenny, i have to put, this line:
    #define OPENSSL_NO_SSL2

    at the top of the /httpd-2.4.3/support/ab.c file.
    before the “make” command.

    If this line is not present, i always have this error:
    httpd-2.4.3/support/ab.c:2227: undefined reference to `SSLv2_client_method’

    Best regards

  6. Instead of altering each vhost config, this works, put in the main config file (e.g. httpd.conf):

    AddHandler fcgid-script .php
    Options +ExecCGI
    FCGIWrapper /usr/lib/cgi-bin/php5 .php

  7. Oops, lost a couple of lines there, should begin with this line in angle brackets

    Ifmodule mod_fcgid.c

    And end with this one with angle brackets either end:

    /IfModule

  8. Does it work for rhel? i need to install 2 apache servers in rhel.
    Please let me know how to do it in Redhat.

  9. Thanks for your reply Mario
    I read in many blogs that if we have to run multiple Apache instances in single redhat machine we have to tweak init.d file.
    Please let me know if there is such configuration required.

    Suppose If we install two Apache 2.4 instances prefix=/opt/apache2,and –prefix=/opt/apache2_4 then there will be two httpd.conf files, please let me know how to start both instances.

  10. I have compiled and installed the Apache2.4.10 in /opt/apache21 and tried starting the severer using apachectl -k start.
    below is the error:

    >>/opt/apache21/bin% apachectl -k start
    Passing arguments to httpd using apachectl is no longer supported.
    You can only start/stop/restart httpd using this script.
    If you want to pass extra arguments to httpd, edit the
    /etc/sysconfig/httpd config file.
    AH00548: NameVirtualHost has no effect and will be removed in the next release /etc/httpd/conf/httpd.conf:82
    (13)Permission denied: AH00058: Error retrieving pid file /run/httpd/httpd.pid
    AH00059: Remove it before continuing if it is corrupted.

    Please let me know am i doing anything wrong.

  11. Now it says httpd is already running if i start to run the second Apache instance

Leave a Reply

Your email address will not be published. Required fields are marked *