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 https://httpd.apache.org/download.cgi.

More information about HTTP/2: https://http2.github.io/

More information on how to build apache2 and configure with HTTP/2 support: http://icing.github.io/mod_h2/howto.html

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.

#!/bin/bash
set -e

APACHE_INSTALL_DIR="/home/user/apache2"
APACHE_VERSION="httpd-2.4.17"
APACHE_SRC_FILE="http://www.us.apache.org/dist/httpd/${APACHE_VERSION}.tar.gz"
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
wget $APACHE_SRC_FILE
# Unarchive the source files
tar -xzvf "${APACHE_VERSION}.tar.gz"
pushd $APACHE_VERSION

# Build from source nghttp2
git clone https://github.com/tatsuhiro-t/nghttp2.git
pushd nghttp2
sudo apt-get install -y $NGHTTP2_DEPS
autoreconf -i
automake
autoconf
sudo ./configure --prefix=/usr/local
sudo make
sudo make install
popd

# 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/mod_http2.so

<IfModule http2_module>
    LogLevel http2:info
</IfModule>

Protocols h2c http/1.1
DELIM

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 »