on my way…

Enable HTTP2 for WordPress on nginx Ubuntu 14.04

HTTP2 is enabled on mainline version of nginx (v1.9.x), while Ubuntu 14.04 is using nginx 1.4.6.
To enable HTTP2, the simplest way is to upgrade nginx to the mainline version.
But I met several issues during the upgrade, and here’re the steps, the issues and solutions.

The solution is to remove old nginx on Ubuntu and re-install mainline nginx.

sudo apt-get remove nginx-common
sudo apt-get install nginx

Now nginx is upgraded to 1.9.11

Config file changes

Previously the site config files are stored in /etc/nginx/site-available, and the enabled sites are soft-linked in /etc/nginx/site-enabled/.
But mainline nginx only load config files in /etc/nginx/conf.d/*.conf.
So either copy the old config files to conf.d, or add include /etc/nginx/sites-enabled/ in nginx.conf.

Mainline nginx’s user is nginx, but Ubuntu uses www-data, so change it in nginx.conf.

#user nginx;
user www-data;

Change spdy to http2 in site config.

Reload nginx, and now the site’s HTTP2 is working.
However, try to open any page of WordPress, it just shows a blank page without any error. The log shows HTTP 200 OK.

Blank page issue

After googling the issue, it’s found that a missing FastCGI param is the root cause.
Add below line in /etc/nginx/fastcgi_params: