使用nginx-build将第三方模块集成到nginx中

nginx的第三方模块

要将第三方模块集成到nginx中,需要在编译nginx本体时静态地进行。这是nginx相对于Apache而言的几个繁琐之一。具体而言,可以通过–add-module来指定要集成模块的路径。

$ ./configure --add-module=サードパーティモジュールのパス

和将依赖库静态地嵌入到nginx中一样,这项工作也稍微有些繁琐。nginx-build具备自动化这一过程的机制。

使用nginx-build将第三方模块集成到nginx中。

要将第三方模块添加到nginx-build中,需要准备类似以下的ini文件。

[echo-nginx-module]
form=git
url=https://github.com/openresty/echo-nginx-module.git
rev=v0.58

[headers-more-nginx-module]
form=git
url=https://github.com/openresty/headers-more-nginx-module.git
rev=v0.28

只需使用-m选项指定该文件并执行。

$ nginx-build -v 1.7.0 -d work -m modules3rd.ini
nginx-build: 0.6.2
Compiler: gc go1.5.2
2015/12/08 04:52:49 Download headers-more-nginx-module-v0.28.....
2015/12/08 04:52:49 Download nginx-1.9.7.....
2015/12/08 04:52:49 Download echo-nginx-module-v0.58.....
2015/12/08 04:53:03 Extract nginx-1.9.7.tar.gz.....
2015/12/08 04:53:03 Generate configure script for nginx-1.9.7.....
2015/12/08 04:53:03 Configure nginx-1.9.7.....
2015/12/08 04:53:10 Build nginx-1.9.7.....
2015/12/08 04:53:15 Complete building nginx!

nginx version: nginx/1.9.7
built by clang 7.0.0 (clang-700.1.76)
configure arguments: --with-cc-opt=-Wno-deprecated-declarations --add-module=../echo-nginx-module --add-module=../headers-more-nginx-module

2015/12/08 04:53:15 Enter the following command for install nginx.

   $ cd work/nginx/1.9.7/nginx-1.9.7
   $ sudo make install

只需要一种选项:
可以从指定的URL通过git clone下载并直接集成到nginx。目前还没有对无法通过git clone下载的情况进行处理。

广告
将在 10 秒后关闭
bannerAds