How to Enable HTTP/2 for Apache in CWP with mod_http2 module

by Sandeep B.

In this tutorial We’ll install Apache 2.4 and enable HTTP/2 Support in CWP. HTTP/2 will make our applications faster, simpler, and more robust — a rare combination — by allowing us to undo many of the HTTP/1.1 workarounds previously done within our applications and address these concerns within the transport layer itself. Even better, it also opens up a number of entirely new opportunities to optimize our applications and improve performance!

How to Enable HTTP/2 on CWP7 NGINX

The primary goals for HTTP/2 are to reduce latency by enabling full request and response multiplexing, minimize protocol overhead via efficient compression of HTTP header fields, and add support for request prioritization and server push. To implement these requirements, there is a large supporting cast of other protocol enhancements, such as new flow control, error handling, and upgrade mechanisms, but these are the most important features that every web developer should understand and leverage in their applications.

This tutorial is now old to enable http/2 and TLS1.3 go to New tutorial :

It is recommended to upgrade to CWP7/Centos 7 since cwp6/centos 6 is getting old.

Ensure you already have SSL certs/LE certs installed for your domains HTTP2 will only work with HTTPS

Please note it will not work on openvz 6

let’s get started

Ensure you’ve root access and ssh access in order to install/upgrade this packages :-

Upgrading OS to latest version :

yum clean all
yum -y update

Upgrading Autoconf :

cd /usr/local/src
rm -rf autoconf-*
tar zxvf autoconf-latest.tar.gz
cd autoconf-*/
./configure --prefix=/usr
make && make install

Installing openssl :

cd /usr/local/src
rm -rf  openssl*
tar zxvf openssl-1.1.1k.tar.gz
cd openssl-1.1.1k
./config --prefix=/usr/local/opensslso --openssldir=/usr/local/opensslso zlib shared
make && make install

*Building openssl will take some time

Installing Nghttp2 :

nghttp2 is an implementation of HTTP/2

cd /usr/local/src
rm -rf nghttp2-*
yum install libtool -y
tar zxvf nghttp2-1.42.0.tar.gz
cd nghttp2-*/
./configure --prefix=/usr
make && make install

Install APR:

cd /usr/local/src
rm -rf apr*
tar -xf apr-1.6.5.tar.gz
tar -xf apr-util-1.6.1.tar.gz
cd /usr/local/src/apr-1.6.5
./configure --prefix=/usr/local/apr1
make install
cd /usr/local/src/apr-util-1.6.1
./configure --with-apr=/usr/local/apr1 --prefix=/usr/local/apr-util1
make install

Rebuilding Apache with http2 support from CWP GUI :

First backup the httpd.conf

cp /usr/local/apache/conf/httpd.conf /usr/local/apache/conf/httpd.conf.bak

Goto Apache Settings >> Apache Re-Build >> Select Next :

Next delete/replace all with this flags/lines under “Additional configuration” :


then Click on Start Compiler in background.

After you builded Apache we need to enable HTTP/2 withing Apache config :

nano /usr/local/apache/conf.d/http2.conf

then add this line and save it :

LoadModule http2_module modules/
LogLevel http2:info
Protocols h2 h2c http/1.1


You can also use this command to create and add the lines automatically :

cat > /usr/local/apache/conf.d/http2.conf << EOF
LoadModule http2_module modules/
LogLevel http2:info
Protocols h2 h2c http/1.1

Restart Apache :

service httpd restart

you can check http/2 is enabled or not via this site:

If something goes wrong restore the Apache httpd.conf backup :

rm -rf /usr/local/apache/conf/httpd.conf
cp /usr/local/apache/conf/httpd.conf.bak /usr/local/apache/conf/httpd.conf
service httpd restart

If this post helps you in any way please consider a donation

Donate with PayPal :


You may also like


David September 2, 2018 - 1:44 pm Reply
David September 2, 2018 - 2:21 pm

Ok, it took an hour plus to get back online…

David September 2, 2018 - 2:32 pm

Ok, I’ve finished this tutorial but still get negative when testing one of my sites.
Was it ok if I’ve followed this tutorial on a server built with Apache+Nginx+Varnish?

Sandy September 2, 2018 - 2:47 pm

Apache only, use nginx one for varnish, nginx and apache

David September 3, 2018 - 5:17 am

Not quite clear. If I use Apache+Nginx+Varnish I can’t have http2 or is that not the correct tutorial to use to implement it?

Sandy September 3, 2018 - 6:27 am

here is the post to enable http2 on nginx (cwp7)

mshastchi September 11, 2018 - 3:09 pm

After all the steps I get the following error restarting apache:

httpd: Syntax error on line 3 of /usr/local/apache/conf/httpd.conf: Syntax error on line 1 of /usr/local/apache/conf.d/http2.conf: Cannot
load modules/ into server: /usr/local/apache/modules/ cannot open shared object file: No such file or directory

And indeed there is no in the directory

Sandy September 11, 2018 - 11:03 am

try to install openssl from the post and try to follow the steps again

RuiP November 5, 2018 - 12:11 pm

i have this issue too….
/usr/local/apache/conf/httpd.conf: Syntax error on line 1 of /usr/local/apache/conf.d/http2.conf: Cannot
load modules/ into server: /usr/local/apache/modules/ cannot open shared object file: No such file or directory

And indeed there is no in the directory

Dave June 9, 2019 - 12:22 pm

Do you recommend upgrading to openssl 1.1.1?

Sandy June 9, 2019 - 6:32 pm

yes you can use it.

Dave June 9, 2019 - 7:10 pm

Yeah i used both latest version for openssl and Nghttp2. Its working now tls 1.3 too automatically, you should update the guide.

Sandy June 14, 2019 - 7:55 pm

Guide updated

Hannah January 1, 2020 - 2:41 pm

Very helpful and worked immediately, just had to remove two .htaccess files throwing errors after upgrade.
Anyone reading getting error 500, check your error logs for deprecated functions!

Sandy January 1, 2020 - 3:37 pm

thanks for the info
mainly “options” functions will not work in htaccess

Faisal Shikder August 22, 2021 - 5:30 pm

HTTP/3 is arrived. Can you make a tutorial on it?

Sandeep B. August 26, 2021 - 1:31 am

hi soon when it is stable.


Leave a Comment