How to Enable HTTP/2 in Apache

cPanel administrators can log into WebHost Manager (WHM) and enable HTTP/2 with EasyApache4 with a slider. Unmanaged server administrators don’t have that pretty graphical interface for this task, excluding maybe those using Webmin, Vesta Control Panel, or another system administration interface. 

Regardless, it is still a quick, straight-forward process to enable HTTP/2 support on Apache web servers. Below we’ll cover how to:

This article does not apply to NGINX servers.

Enable HTTP/2 in Apache

  1. SSH into your server as the root user.
  2. Ensure you have Apache installed (Ubuntu/CentOS) and the version is at least 2.4. Otherwise, you’ll need to upgrade Apache.
    apachectl -v
  3. Ensure you have a valid SSL certificate installed on your server so you can use force secure (HTTPS) connections. If you need one, you can use the free Certbot Let’s Encrypt SSL application on Ubuntu 18.04.

    Unfortunately, snapd is not compatible with our Cloud Server Hosting at this time. Instead, install Certbot with PIP (Python Installs Packages).

  4. Enable the HTTP/2 Apache module:
    a2enmod http2
  5. Edit your Apache virtual host configuration file with your preferred text editor – e.g. Nano, Emacs, VIM, etc. If you have an SSL installed, the file should end with le-ssl. One of the following should work depending on your server environment:
    sudo nano /etc/apache2/sites-enabled/domainname-le-ssl.conf
    sudo nano /etc/apache2/sites-enabled/000-default-le-ssl.conf
  6. Add the following text in the configuration file directly underneath <VirtualHost *:443>:
    Protocols h2 http/1.1
  7. Save changes.
  8. Restart Apache:
    apachectl restart

If you have issues configuring HTTP/2 at any time, you can always request technical support from our Managed Hosting team.

Verify HTTP/2 Support

After reconfiguring Apache, you’ll need to use browser developer tools or third party extensions to verify that your website is using HTTP/2. The fastest option is to use an online tool such as the KeyCDN HTTP/2 test tool. 

Linux terminal users can use the following command to check if their website is using HTTP/2:

curl --http2 domain.com -I

The response should start with HTTP/2 200.

Using localhost instead of the domain or server hostname while logged into SSH may not work.

KeyCDN HTTP/2 test

If you want to stay ahead on website performance, look out for the upcoming HTTP/3 protocol. As of November 2020, Firefox, Chrome, Edge, and Safari support HTTP/3. However, Safari is the only web browser with HTTP/3 support enabled by default. Meanwhile, native Nginx HTTP/3 support is expected to come in the 1.19 release.

Looking for other ways to improve website performance? Learn more about how to secure your Linux cloud server.

Learn more from our Cloud Server Hosting Product Guide.

InMotion Hosting Contributor
InMotion Hosting Contributor Content Writer

InMotion Hosting contributors are highly knowledgeable individuals who create relevant content on new trends and troubleshooting techniques to help you achieve your online goals!

More Articles by InMotion Hosting

Was this article helpful? Join the conversation!