由于官网目前能下载到的nginx-1.11.4不支持http2:
D:\http2\nginx-1.11.4>nginx -s reload
nginx: [emerg] the "http2" parameter requires ngx_http_v2_module in D:\http2\nginx-1.11.4/conf/nginx.conf:98
原因是官方编译的时候没有带上--with-http_v2_module,因此需要重新编译nginx
要在windows下编译,太痛苦了吧,还是移师mac吧
重新编译nginx需要依赖以下模块:
-
gzip模块需要zlib库 —- 已经有了 -
rewrite模块需要pcre库 —- 不需要编译,只需要编译nginx的时候指定源码路径 -
ssl功能需要openssl库 —- 已经有了,但是怕内建的版本太旧不支持ALPN,还是重新下载编译吧
1. 编译OpenSSL
在http://www.openssl.org/source下载当前最新的版本源码
解压缩openssl-xx.tar.gz包, 进入解压缩目录,执行:
./config
make
sudo make install
2. 编译Nginx
在http://www.pcre.org下载当前最新的版本的pcre源码
在http://nginx.org/en/download.html下载当前最新的版本的nginx源码
解压缩pcre-xx.tar.gz、nginx-xx.tar.gz包,进入解压缩目录,执行:
./configure --with-pcre=/Users/enzo/http2/pcre-8.39 --with-http_v2_module --with-http_ssl_module
make
sudo make install
Ok,完成!