Tutorial

How to Enable HTTP/2 NGINX for WordPress Website

Enable HTTP/2 on your webserver and speed up your blog, website, or application. HTTP/2 improves the speed by loading all scripts, CSS parallel instead of one by one. You can read more about HTTP/2 at Google official.

Enable HTTP/2 in Bitnami NGINX
Enable http2 in Bitnami NGINX

How HTTP/2 boost the speed of a website or blog?

On HTTP1.1, every website component loads one after another, but in HTTP/2, each type of file loads together synchronously. That means it loads all CSS files in once and then JS, so the time taken is less than HTTP/1.1. So it will be a good practice to enable HTTP/2 for your web server.

The HTTP/2 is a lot faster than that of HTTP1.1. So it would be best if you considered enabling the HTTP/2 feature.

How to Enable HTTP/2?

You can enable HTTP/2 just by editing bitnami.conf file of your bitnami WordPress nginx stack. To do this, you’ve to execute the following command.

sudo -i

Command for older structure for Bitnami WordPress NGINX

nano opt/bitnami/nginx/conf/bitnami/bitnami.conf

If you installed bitnami stack on or after 17 May 2021, execute the following command.

nano /opt/bitnami/nginx/conf/server_blocks/wordpress-https-server-block.conf

Now the .conf file will open up. You’ve to add http2 in the 443 server connection block as displayed below.

server {
        listen 443 ssl http2;
        server_name  localhost;
       ssl_certificate      server.crt;
       ssl_certificate_key  server.key;
        ssl_certificate      
        ssl_session_cache    shared:SSL:1m;
        ssl_session_timeout  5m;

        ssl_session_tickets off;
        ssl_stapling on;
        ssl_stapling_verify on;
        ssl_ciphers  HIGH:!aNULL:!MD5;
#       ssl_prefer_server_ciphers  on;
#        include "/opt/bitnami/nginx/conf/bitnami/phpfastcgi.conf";
       include "/opt/bitnami/nginx/conf/bitnami/bitnami-apps-prefix.conf";
    }

Save the settings by pressing ctrl+X, then Y, and then press enter to update the changes.

Now you can check that all the settings you made are correct using the following command line.

nginx -t

If all settings are correct, you can restart nginx to load a new configuration.

sudo /opt/bitnami/ctlscript.sh restart nginx

After the restart, you can check the HTTP/2 status of your website, which will result as enabled. Improve server security by hiding the nginx server version.

Ashok Kumar

Ashok Kumar working in the Search Engine Optimization field since 2015. And worked on many successful projects since then. He shares the real-life experience of best SEO practices with his followers on seoneurons.com. You also can learn Advance level SEO for WordPress, Blogger, or any other blogging platform. Stay tuned.

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button