Skip to content

Instantly share code, notes, and snippets.

@WebDevJL
Last active November 19, 2017 21:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save WebDevJL/6fa52c1626337537e58157626abc825f to your computer and use it in GitHub Desktop.
Save WebDevJL/6fa52c1626337537e58157626abc825f to your computer and use it in GitHub Desktop.
Ubuntu 16.04: enable http2 for Apache2
#!/bin/bash
# $1 => UNIX user as parameter
# Done and working in a Linode 1GB on Nov, 19th.
cd ~
# to enable http/2, copy these lines into /etc/apt/sources.list
su -
vim /etc/apt/sources.list
#deb-src http://archive.ubuntu.com/ubuntu/ xenial main universe restricted multiverse
#deb-src http://security.ubuntu.com/ubuntu xenial-security main universe restricted multiverse
#deb-src http://archive.ubuntu.com/ubuntu/ xenial-updates main universe restricted multiverse
apt-get update && apt-get upgrade
apt-get install curl devscripts build-essential fakeroot
echo "Switch to the main user on the VPS (except root user)"
su $1
cd ~
sudo apt-get install libnghttp2-dev
mkdir apache2
cd apache2
apt-get source apache2
sudo apt-get build-dep apache2
cd apache2-2.4.18
sudo apt-get install curl devscripts build-essential fakeroot
fakeroot debian/rules binary
sudo cp debian/apache2-bin/usr/lib/apache2/modules/mod_http2.so /usr/lib/apache2/modules/
exit
vim /etc/apache2/mods-available/http2.load
# And copy the following (and remove the comment characters):
#LoadModule http2_module /usr/lib/apache2/modules/mod_http2.so
#<IfModule http2_module>
#LogLevel http2:info
#</IfModule>
echo "Enable the HTTP2 module"
a2enmod http2
vim /etc/apache2/apache2.conf
# add at the end:
#Protocols h2 http/1.1
apachectl configtest
service apache2 restart
cd ~
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment