Movatterモバイル変換


[0]ホーム

URL:


Skip to content
DEV Community
Log in Create account

DEV Community

Cover image for Enabling HTTP/2 in Apache on Ubuntu
Ayekple Clemence
Ayekple Clemence

Posted on • Originally published atanansewaa.com

     

Enabling HTTP/2 in Apache on Ubuntu

The experimentalSPDY protocol originally developed by Google gave birth toHTTP/2. Enabling HTTP/2 will greatly improve website performance.

However, there are some prerequisites to enabling HTTP/2 for your website. In this article, I will show how to get HTTP/2 working on your site running on Apache webserver.

Prerequisites to Enabling HTTP/2

HTTPS

First, enable HTTPS for your site. Configure HTTPS for your website, if you do not already have the SSL certificate or useLet’s Encrypt which is an open-source SSL certificate.

Apache 2.4.24

Older versions of Apache do not support HTTP/2. You need to have Apache 2.4.24 and above. If you are using Ubuntu 16.04 LTS, thenupgrade to Ubuntu 18.04 LTS.

PHP FPM

By default, PHP runs on Apache via mod_php. According to Apache documentation,HTTP/2 is not compatible with Apache’s prefork multi-processing module. Moreover, prefork is not most people favourite now. A switch to a modern module is better.

Therefore, switch to php7.x-fpm from mod_php. Run the following commands to effect the necessary changes.

sudo apt-get install php7.2-fmsudo a2enmod proxy_fcgisudo e2enconf php7.2-fpmsudo a2dismod php7.2sudo a2dismod mpm_preforksudo a2enmod mpm_eventsudo service apache2 restart

Enable HTTP/2 in Apache

Now, let’s enable mod_http2 module. Use the command below to enable mod_http2:

sudo a2enmod http2sudo service apache2 restart

Finally, enable HTTP/2 protocol by updating/etc/apache2/apache2.conf with the code below:

Protocols h2 http/1.1

Conclusion

Now you have successfully enabled HTTP/2 protocol in Apache. Test your configuration withLighthouse which powers the audit panel of Chrome Dev Tools or theonline test from KeyCDN.

Top comments(0)

Subscribe
pic
Create template

Templates let you quickly answer FAQs or store snippets for re-use.

Dismiss

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment'spermalink.

For further actions, you may consider blocking this person and/orreporting abuse

I'm a Fullstack Developer and Blogger. I love trying new things and sharing them
  • Location
    Ghana
  • Work
    Fullstack Developer at University of Cape Coast
  • Joined

More fromAyekple Clemence

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Log in Create account

[8]ページ先頭

©2009-2025 Movatter.jp