The lazy programmer scripts
scripts that work

Lazy build from source apache2 with HTTP/2 support GitHub

This script builds apache2 on Linux with HTTP/2 protocol support.

Tested on Ubuntu 15.04.

Ubuntu 14.10 and 15.04 come by default with apache2 version 2.4.10.

The minimum required version for apache2 with HTTP/2 support is 2.4.17, downloadable from

More information about HTTP/2:

More information on how to build apache2 and configure with HTTP/2 support:

Clients that support HTTP/2 protocol are latest version of curl with libcurl http2 support, Mozilla Firefox Nightly or Google Chrome Canary.

Make sure you do not have apache2 already installed and running on port 80.

set -e

APACHE_DEPS="apache2-dev libapr1-dev libaprutil1-dev libpcre3 libpcre3-dev lynx"
NGHTTP2_DEPS="autoconf automake autotools-dev libtool pkg-config zlib1g-dev libcunit1-dev libssl-dev libxml2-dev libevent-dev make binutils libjansson-dev libjemalloc-dev cython python3.4-dev python-setuptools"

#Install required dependencies
sudo apt-get install -y $APACHE_DEPS

# Download apache2 sources
# Unarchive the source files
tar -xzvf "${APACHE_VERSION}.tar.gz"

# Build from source nghttp2
git clone
pushd nghttp2
sudo apt-get install -y $NGHTTP2_DEPS
autoreconf -i
sudo ./configure --prefix=/usr/local
sudo make
sudo make install

# Build apache2
sudo ./configure --enable-http2 --prefix=$APACHE_INSTALL_DIR
sudo make
sudo make install

# now we should have $APACHE_INSTALL_DIR/bin/httpd and apachectl binaries
sudo chown -R www-data.www-data "${APACHE_INSTALL_DIR}/htdocs"
sudo "${APACHE_INSTALL_DIR}/bin/apachectl" -k start
# now if you navigate to http://localhost you should see "It works!"

# enabling http/2 protocol
sudo tee -a "${APACHE_INSTALL_DIR}/conf/httpd.conf" <<DELIM
LoadModule http2_module modules/

<IfModule http2_module>
    LogLevel http2:info

Protocols h2c http/1.1

sudo "${APACHE_INSTALL_DIR}/bin/apachectl" -k restart

That's all, folks!

Written by kami on Tuesday October 20, 2015
Permalink - Tags: ubuntu, bash, git, webserver, apache2, apt-get

Leave a comment

comments powered by Disqus

« Lazy Windows show stats - Lazy install Riak from source »