Wireless Army
This is a blog / tips and tricks website for web developers and security researchers.
follow us in feedly


build apache2 from source
by admin
 at 2016-01-14 07:02:47.

this could helpful if apt-get install apache installs an old version or you want to play around with h2 http2.0 protocal

first we have to install the dependencies

sudo apt-get install g++ make binutils autoconf automake autotools-dev libtool pkg-config \ zlib1g-dev libcunit1-dev libssl-dev libxml2-dev libev-dev libevent-dev libjansson-dev \libjemalloc-dev cython python3-dev python-setuptools libapr1-dev libaprutil1-dev

then install nghttp2 for http2 protocal 

git clone https://github.com/tatsuhiro-t/nghttp2.git
autoreconf -i
automake
autoconf
./configure
make
make install
ln -s /usr/local/lib/libnghttp2.so /lib/x86_64-linux-gnu/libnghttp2.so.5
ldconfig

now finally we can start downloading apache 2.4.18

wget http://apache.mirror.gtcomm.net//httpd/httpd-2.4.18.tar.bz2
tar -jxvf httpd-2.4.18.tar.bz2
./configure --prefix=/usr/local/apache2 --enable-mods-shared=all --enable-so --enable-http2 --with-nghttp2=/usr/local --enable-nghttp2-staticlib-deps --enable-proxy --with-mpm=event
--enable-ssl --enable-ssl-staticlib-deps make make install

if you want to install arp (Apache Portable Runtime) download the latest version and copy the inside apache download directory under srclib

wget http://apache.sunsite.ualberta.ca//apr/apr-1.5.2.tar.gz
wget http://apache.sunsite.ualberta.ca//apr/apr-util-1.5.4.tar.gz
tar -zxvf apr-1.5.2.tar.gz
tar -zxvf apr-util-1.5.4.tar.gz
cp -R apr-1.5.2 httpd-2.4.18/srclib/apr/
cp -R apr-util-1.5.4 httpd-2.4.18/srclib/apr-util/

and then add --with-included-apr to your ./configure line

to start or stop your server you have to

cd /usr/local/apache2/bin
./apachectl start
./apachectl stop
./apachectl restart

if you want to install php from source, here is a guide
also not that command like a2enmod a2ensite only work if you have installed apache with apt-get install

in order to change those you have to edit /usr/local/apache2/conf/httpd.conf to use http 2.0 you need to add the following lines to httpd.conf:

LoadModule http2_module modules/mod_http2.so
<IfModule http2_module>
    LogLevel http2:info
</IfModule>
# for a https server
Protocols h2 http/1.1
# for a http server
Protocols h2c http/1.1

for testing you can run nghttp -uv http://mysite

now to make it start with boot

cp /usr/local/apache2/bin/apachectl /etc/init.d/apachectl

and then add

### BEGIN INIT INFO
# Provides:          apache
# Required-Start:    $remote_fs $syslog
# Required-Stop:     $remote_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Example initscript
# Description:       This file should be used to construct scripts to be
#                    placed in /etc/init.d.
### END INIT INFO

after #!bin/sh

and then

update-rc.d -f apache2 remove
update-rc.d apachectl defaults
update-rc.d apachectl enable

from now on you can use the commands service apachectl start | stop | restart