ã¤ã³ãã©ãã¼ã ã®@cubicdaiyaã§ããä»åã¯nginxã®ãã«ãããã»ã¹ãèªååãããã¼ã«ã§ããnginx-buildã«ã¤ãã¦ç´¹ä»ãã¾ãã
ã¡ã«ã«ãªã¨nginx
ã¡ã«ã«ãªã§ã¯å¤æ°ã®nginxãæ´»ç¨ããé«éãªã¬ã¹ãã³ã¹ããµã¼ãã¹ã®å®å®ç¨¼åãå®ç¾ããã®ã«éè¦ãªå½¹å²ãæããã¦ãã¾ããå®éã®æ´»ç¨äºä¾ã«ã¯ã
- ãªãã¼ã¹ãããã·ãL7ãã¼ããã©ã³ãµ
- TLSã¿ã¼ããã¼ã·ã§ã³ãSPDYã²ã¼ãã¦ã§ã¤
- éçã³ã³ãã³ãã®é ä¿¡ããã£ãã·ã¥
- ngx_dynamic_upstreamãç¨ããã¼ããã¦ã³ã¿ã¤ã ãããã¤ã¡ã³ã
- ngx_lua(OpenResty)ãç¨ãããµã¼ãã¹ã³ã³ãã¼ãã³ãã®éçº
ãªã©ãæãããã¾ããããã¦ã¡ã«ã«ãªã§ã¯ãããå¤æ°ã®ç¨éã®nginxãnginx-buildã§ã½ã¼ã¹ã³ã¼ããããã«ããã¦ãã¾ãã(OpenResty以å¤ã¯åããã¦rpmåãè¡ã£ã¦ãã¾ã)
æ¢åã®ãã«ãæ¸ã¿ããã±ã¼ã¸ã®å©ç¨ã¨ã½ã¼ã¹ã³ã¼ãããã®ãã«ã
nginxã¯yumãaptã¨ãã£ãåLinuxãã£ã¹ããªãã¥ã¼ã·ã§ã³ã®ããã±ã¼ã¸ç®¡çãã¼ã«ã§ãã«ãæ¸ã¿ã®ããã±ã¼ã¸ãã¤ã³ã¹ãã¼ã«ãããã¨ãã§ãã¾ãããå ¬å¼ãµã¤ãã§ããã«ãæ¸ã¿ããã±ã¼ã¸ãé å¸ãã¦ãã¾ããã¤ã³ã¹ãã¼ã«ãç°¡åãªã®ã§ç¹ã«ãã ãããçç±ããªããã°åºãé å¸ããã¦ãããã«ãæ¸ã¿ããã±ã¼ã¸ãå©ç¨ããã ãã§åé¡ãªãã§ãããã
ä¸æ¹ã§æ¢åã®ãã«ãæ¸ã¿ããã±ã¼ã¸ãå©ç¨ããå ´å以ä¸ã®ãã¡ãªãããæãããã¾ãã
- ãã«ãæã®
configure
ãªãã·ã§ã³ãé¸ã¹ãªã(æ¢ã«æ±ºã¾ã£ã¦ãã) - ãµã¼ããã¼ãã£ã®ã¢ã¸ã¥ã¼ã«ãçµã¿è¾¼ããªã
ã1. ãã«ãæã®configure
ãªãã·ã§ã³ãé¸ã¹ãªãããåé¡ã«ãªããã¨ã¯å°ãªãããããã¾ããããã2. ãµã¼ããã¼ãã£ã®ã¢ã¸ã¥ã¼ã«ãçµã¿è¾¼ããªããã¯å¤§ããªãã¤ãã¹ãã¤ã³ãã§ããã¨ããã®ãnginxã®ã¢ã¸ã¥ã¼ã«ã¯ãã¹ã¦ãã«ãæã«çµã¿è¾¼ãå¿
è¦ãããããã§ãã(ãã®ç¶æ³ã¯ä»å¾å¤ããããããã¾ããã詳ããã¯ãã¡ã)
nginxãã½ã¼ã¹ã³ã¼ããããã«ããã
次ã«nginxãã½ã¼ã¹ã³ã¼ããããã«ãããæé ãæ¸ãã¦ã¿ã¾ãã
wget http://nginx.org/download/nginx-1.9.4.tar.gz tar zxf nginx-1.9.4.tar.gz cd nginx-1.9.4 ./configure make make install
é常ã«ç°¡åã§ãããããnginxãæ¬æ ¼çã«ãããã¯ã·ã§ã³ã§å©ç¨ããå ´åã¯èããªããã°ãªããªããã¨ãæ°å¤ãããã¾ããããã¨æãã¤ããã®ãæãã¦ã¿ã¾ãã
- 大éã«ãããã«ããªãã·ã§ã³ã®æå®
- PCREãzlibãOpenSSLãªã©ã®ä¾åã©ã¤ãã©ãªã®çµã¿è¾¼ã¿ã»ãã¼ã¸ã§ã³ç®¡ç
- ãµã¼ããã¼ãã£ã¢ã¸ã¥ã¼ã«ã®çµã¿è¾¼ã¿ã»ãã¼ã¸ã§ã³ç®¡ç
- ä¸è¨æé ã®èªååã»æ§æ管çã»ã¡ã³ããã³ã¹
ãããã®æéãå¤§å¹ ã«çãããã«éçºããã®ã次ã«ç´¹ä»ããnginx-buildã§ãã
nginx-buildãseamless nginx builderã
nginx-buildã¯nginxã®ãã«ãããã»ã¹ãèªååããããã®ãã¼ã«ã§ããGoã§æ¸ããã¦ãã¾ãã
ãã¡ããããã«ãæ¸ã¿ã®å®è¡ãã¤ããªããã¦ã³ãã¼ããããã¨ãã§ãã¾ããMacã¦ã¼ã¶ãªãHomebrewã§ã¤ã³ã¹ãã¼ã«ãããã¨ãå¯è½ã§ãã
brew tap cubicdaiya/nginx-build brew install nginx-build
ã¾ããGoãã¤ã³ã¹ãã¼ã«ããã¦ããã°go get
ã§ã¤ã³ã¹ãã¼ã«ãããã¨ãã§ãã¾ãã
go get -u github.com/cubicdaiya/nginx-build
nginx-buildã§nginxããã«ããã
ããã§ã¯nginx-build
ã§nginxããã«ããã¦ã¿ã¾ãããã
$ nginx-build -d work -v 1.9.4 nginx-build: 0.4.4 Compiler: gc go1.5 2015/08/23 21:37:57 Download nginx-1.9.4..... 2015/08/23 21:38:03 Extract nginx-1.9.4.tar.gz..... 2015/08/23 21:38:03 Generate configure script for nginx-1.9.4..... 2015/08/23 21:38:03 Configure nginx-1.9.4..... 2015/08/23 21:38:08 Build nginx-1.9.4..... 2015/08/23 21:38:12 Complete building nginx! nginx version: nginx/1.9.4 built by gcc 4.4.7 20120313 (Red Hat 4.4.7-3) (GCC) configure arguments: 2015/08/23 21:38:12 Enter the following command for install nginx. $ cd work/1.9.4/nginx-1.9.4 $ sudo make install $
nginx-build
ãè¡ãã®ã¯ã½ã¼ã¹ã³ã¼ããã©ã¤ãã©ãªã®ãã¦ã³ãã¼ãã¨ã³ã³ãã¤ã«ã¾ã§ãªã®ã§å¾ã¯åºåã«ãããã£ã¦ã¤ã³ã¹ãã¼ã«(make install
)ãã¾ãã
configureãªãã·ã§ã³ãæå®ãã
nginx-build
ã«ã¯nginxã®configure
ã®ãªãã·ã§ã³ãç´æ¥ä»å ãããã¨ãã§ãã¾ãã
$ nginx-build \ > -d work \ > -v 1.9.4 \ > --with-http_gzip_static_module \ > --with-http_gunzip_module \ > --with-http_stub_status_module \ > --with-http_realip_module nginx-build: 0.4.4 Compiler: gc go1.5 2015/08/23 21:36:11 nginx-1.9.4 already exists. 2015/08/23 21:36:11 Generate configure script for nginx-1.9.4..... 2015/08/23 21:36:11 Configure nginx-1.9.4..... 2015/08/23 21:36:15 Build nginx-1.9.4..... 2015/08/23 21:36:20 Complete building nginx! nginx version: nginx/1.9.4 built by gcc 4.4.7 20120313 (Red Hat 4.4.7-3) (GCC) configure arguments: --with-http_gunzip_module --with-http_stub_status_module --with-http_realip_module --with-http_gzip_static_module 2015/08/23 21:36:20 Enter the following command for install nginx. $ cd work/1.9.4/nginx-1.9.4 $ sudo make install $
ãªããªãã·ã§ã³ãç´æ¥ä¸ããæ¹æ³ã«ã¯ã»ãã®å°ãã ãå¶éãããã®ã§configure
ã®å®è¡ã¹ã¯ãªããããã¡ã¤ã«ã§æå®ããæ¹æ³ãç¨æãã¦ãã¾ãã
#!/bin/sh ./configure \ --with-http_gzip_static_module \ --with-http_gunzip_module \ --with-http_stub_status_module \ --with-http_realip_module
ãã®ã·ã§ã«ã¹ã¯ãªãããã¡ã¤ã«ãnginx-build
ã«-c
ãªãã·ã§ã³ã§ä»å ãããã¨ã§nginxã®configure
ãªãã·ã§ã³ãæå®ã§ãã¾ãã
$ nginx-build -d work -v 1.9.4 -c configure.sh nginx-build: 0.4.4 Compiler: gc go1.5 2015/08/23 21:37:02 Download nginx-1.9.4..... 2015/08/23 21:37:07 Extract nginx-1.9.4.tar.gz..... 2015/08/23 21:37:07 Generate configure script for nginx-1.9.4..... 2015/08/23 21:37:07 Configure nginx-1.9.4..... 2015/08/23 21:37:11 Build nginx-1.9.4..... 2015/08/23 21:37:16 Complete building nginx! nginx version: nginx/1.9.4 built by gcc 4.4.7 20120313 (Red Hat 4.4.7-3) (GCC) configure arguments: --with-http_gzip_static_module --with-http_gunzip_module --with-http_stub_status_module --with-http_realip_module 2015/08/23 21:37:16 Enter the following command for install nginx. $ cd work/1.9.4/nginx-1.9.4 $ sudo make install $
ä¾åã©ã¤ãã©ãªã®çµã¿è¾¼ã¿
nginxã«ã¯ããã¤ãä¾åã©ã¤ãã©ãªãããã¾ãã代表çãªã®ã¯ä»¥ä¸ã®3ã¤ã§ãã
nginxã¯ãããã®ã©ã¤ãã©ãªãéçãããã¯åçã«çµã¿è¾¼ããããã«ãªã£ã¦ãã¾ããåççµã¿è¾¼ã¿ã®å ´ånginxã®configureã¹ã¯ãªãããã·ã¹ãã ã®ãã¹ãæ¤ç´¢ãã¦ã©ã¤ãã©ãªã®ãã¹ãçºè¦ãã¦ããã¾ãããéççµã¿è¾¼ã¿ã«å ´åã¯å¥éä¾åã©ã¤ãã©ãªã®ãã¹ãæå®ããå¿ è¦ãããã¾ãã
./configure \ -with-pcre=../pcre-8.37 \ --with-zlib=../zlib-1.2.8 \ --with-openssl=../openssl-1.0.2d
nginx-build
ã¯ãããã®ã©ã¤ãã©ãªã®çµã¿è¾¼ã¿ããã¦ã³ãã¼ããå«ãã¦èªååããããã®ãªãã·ã§ã³ãç¨æãã¦ãã¾ãã
$ nginx-build \ -d work \ -v 1.9.4 \ -pcre \ -pcreversion=8.37 \ -zlib \ -zlibversion=1.2.8 \ -openssl \ -opensslversion=1.0.2d nginx-build: 0.4.4 Compiler: gc go1.5 2015/08/23 21:47:30 Download nginx-1.9.4..... 2015/08/23 21:47:30 Download zlib-1.2.8..... 2015/08/23 21:47:30 Download openssl-1.0.2d..... 2015/08/23 21:47:30 Download pcre-8.37..... 2015/08/23 21:47:32 Extract zlib-1.2.8.tar.gz..... 2015/08/23 21:47:33 Extract pcre-8.37.tar.gz..... 2015/08/23 21:47:34 Extract openssl-1.0.2d.tar.gz..... 2015/08/23 21:47:37 Extract nginx-1.9.4.tar.gz..... 2015/08/23 21:47:37 Generate configure script for nginx-1.9.4..... 2015/08/23 21:47:37 Configure nginx-1.9.4..... 2015/08/23 21:47:41 Build nginx-1.9.4..... 2015/08/23 21:50:47 Complete building nginx! nginx version: nginx/1.9.4 built by gcc 4.4.7 20120313 (Red Hat 4.4.7-3) (GCC) built with OpenSSL 1.0.2d 9 Jul 2015 TLS SNI support enabled configure arguments: --with-pcre=../pcre-8.37 --with-openssl=../openssl-1.0.2d --with-zlib=../zlib-1.2.8 --with-http_ssl_module 2015/08/23 21:50:47 Enter the following command for install nginx. $ cd work/1.9.4/nginx-1.9.4 $ sudo make install $
--with-http_ssl_module
ã¯OpenSSLé¢é£ã®ãªãã·ã§ã³ãæå®ããã¨èªåçã«ä»å ããã¾ãã(ã§ãªãã¨ã³ã³ãã¤ã«ã«å¤±æãã¦ãã¾ãã®ã§)
ãµã¼ããã¼ãã£ã¢ã¸ã¥ã¼ã«ã®çµã¿è¾¼ã¿
nginxã«ãµã¼ããã¼ãã£ã®ã¢ã¸ã¥ã¼ã«ãçµã¿è¾¼ãã«ã¯--add-module
ãªãã·ã§ã³ãå©ç¨ãã¾ãã
./configure --add-module={ã¢ã¸ã¥ã¼ã«ã®ãã¹}
å
è¿°ã®éãnginx-build
ã§ã¯nginxã®configure
ã®ãªãã·ã§ã³ãç´æ¥æå®åºæ¥ãã®ã§--add-module
ãå©ç¨å¯è½ã§ããããã§ã¯echo-nginx-moduleã¨headers-more-nginx-moduleãçµã¿è¾¼ãã§ã¿ã¾ãã
$ git clone https://github.com/openresty/echo-nginx-module.git $ git clone https://github.com/openresty/headers-more-nginx-module.git $ nginx-build \ -d work \ -v 1.9.4 \ --add-module=echo-nginx-module \ --add-module=headers-more-nginx-module nginx-build: 0.4.4 Compiler: gc go1.5 2015/08/23 22:05:26 Download nginx-1.9.4..... 2015/08/23 22:05:32 Extract nginx-1.9.4.tar.gz..... 2015/08/23 22:05:32 Generate configure script for nginx-1.9.4..... 2015/08/23 22:05:32 Configure nginx-1.9.4..... 2015/08/23 22:05:37 Build nginx-1.9.4..... 2015/08/23 22:05:42 Complete building nginx! nginx version: nginx/1.9.4 built by gcc 4.4.7 20120313 (Red Hat 4.4.7-3) (GCC) configure arguments: --add-module=/home/bokko/nginx/echo-nginx-module --add-module=/home/bokko/nginx/headers-more-nginx-module 2015/08/23 22:05:42 Enter the following command for install nginx. $ cd work/1.9.4/nginx-1.9.4 $ sudo make install $
ããã»ã©ã®ä¾åã©ã¤ãã©ãªçµã¿è¾¼ã¿ã®ä¾ã§ã¯ãã¦ã³ãã¼ããèªååãã¦ãã¾ãããããµã¼ããã¼ãã£ã¢ã¸ã¥ã¼ã«ã«ã¤ãã¦ããã¦ã³ãã¼ãã®èªååã¯å¯è½ã§ãã次ã®ãããªiniãã¡ã¤ã«(modules3rd.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.261
ãã®ãã¡ã¤ã«ãnginx-build
ã«-m
ãªãã·ã§ã³ã§ä»å ãã¾ãã
$ nginx-build -d work -v 1.9.4 -m modules3rd.ini nginx-build: 0.4.4 Compiler: gc go1.5 2015/08/23 22:25:22 Download headers-more-nginx-module-v0.261..... 2015/08/23 22:25:22 Download nginx-1.9.4..... 2015/08/23 22:25:22 Download echo-nginx-module-v0.58..... 2015/08/23 22:25:28 Extract nginx-1.9.4.tar.gz..... 2015/08/23 22:25:28 Generate configure script for nginx-1.9.4..... 2015/08/23 22:25:28 Configure nginx-1.9.4..... 2015/08/23 22:25:32 Build nginx-1.9.4..... 2015/08/23 22:25:37 Complete building nginx! nginx version: nginx/1.9.4 built by gcc 4.4.7 20120313 (Red Hat 4.4.7-3) (GCC) configure arguments: --add-module=../echo-nginx-module --add-module=../headers-more-nginx-module 2015/08/23 22:25:37 Enter the following command for install nginx. $ cd work/1.9.4/nginx-1.9.4 $ sudo make install $
nginxããã«ãããå¾ã«ãã«ãæã®configure
ã®ãªãã·ã§ã³ã確èªããã®ã¯nginx -V
ãå®è¡ãã¾ãããããããµã¼ããã¼ãã£ã¢ã¸ã¥ã¼ã«ã®å ´åãã©ã®ãã¼ã¸ã§ã³ã®ãµã¼ããã¼ãã£ã¢ã¸ã¥ã¼ã«ãçµã¿è¾¼ãã ãã«ã¤ãã¦ã¯ç¢ºèªããã®ãå°é£ã§ãã
ãªã®ã§nginx-build
ã®-m
ãªãã·ã§ã³ãå©ç¨ãã¦ãµã¼ããã¼ãã£ã¢ã¸ã¥ã¼ã«ã®çµã¿è¾¼ã¿æé ããã¡ã¤ã«ã«æ®ãã¦ãããã¨ã¯å¾ã
ã®nginxã®æ§æ管çããããããããããã«ããªãã¾ãã
nginxã®æ´¾çããã¸ã§ã¯ãã¸ã®å¯¾å¿
nginxã«ã¯ä»¥ä¸ã®æ´¾çããã¸ã§ã¯ããåå¨ãã¾ãã
nginx-build
ã¯æ¬å®¶ã®nginxã ãã§ãªããããã®æ´¾çããã¸ã§ã¯ãã®ã½ã¼ã¹ã³ã¼ãã®ãã«ãã«ã対å¿ãã¦ãã¾ãã
OpenResty
OpenRestyã¯nginxã«ngx_luaãã¯ããã¨ãã便å©ãªãµã¼ããã¼ãã£ã¢ã¸ã¥ã¼ã«ãLuaã¨LuaJITãngx_luaåãã®ã¢ã¸ã¥ã¼ã«ç¾¤(restyã¢ã¸ã¥ã¼ã«)ããã³ãã«ããã¢ããªã±ã¼ã·ã§ã³ãã¬ã¼ã ã¯ã¼ã¯ã§ããã¡ã«ã«ãªã§ãä¸é¨ã®ãµã¼ãã¹ã³ã³ãã¼ãã³ãã§å©ç¨ãã¦ãã¾ããnginx-build
ã§OpenRestyããã«ãããã«ã¯-openresty
ãªãã·ã§ã³ãä»å ãã¾ããã¾ãã-openrestyversion
ã§ãã¼ã¸ã§ã³ãæå®ãããã¨ãå¯è½ã§ãã
nginx-build -d work -pcre -openresty -openrestyversion=1.9.3.1
Tengine
Tengineã¯nginxã®ãã©ã¼ã¯ããã¸ã§ã¯ãã§ããã¢ã¸ã¥ã¼ã«ã®åççµã¿è¾¼ã¿ãã¢ããã¹ããªã¼ã ã®ãã«ã¹ãã§ãã¯ãªã©æ¬å®¶ã®nginxã«ã¯å«ã¾ãã¦ããªã(ãããã¯æåçã®NGINX Plusã«ãããªã)便å©ãªæ©è½ãå©ç¨ã§ããã®ãç¹å¾´ã§ããnginx-build
ã§Tengineããã«ãããã«ã¯-tengine
ãªãã·ã§ã³ãä»å ãã¾ããã¾ãã-tengineversion
ã§ãã¼ã¸ã§ã³ãæå®ãããã¨ãå¯è½ã§ãã
nginx-build -d work -tengine -tengineversion=2.1.1
ã¾ã¨ã
nginxã®ãã«ãããã»ã¹ãèªååããããã®ãã¼ã«ã§ããnginx-buildã«ã¤ãã¦ç´¹ä»ãã¾ãããnginx-build
ãå©ç¨ãããã¨ã§ä»¥ä¸ã®ä½æ¥ã®å¤§é¨åãèªååãããã¨ãã§ãã¾ãã
- nginxã®ãã«ã
- ä¾åã©ã¤ãã©ãªã®ãã¦ã³ãã¼ãã¨çµã¿è¾¼ã¿
- ãµã¼ããã¼ãã£ã¢ã¸ã¥ã¼ã«ã®ãã¦ã³ãã¼ãã¨çµã¿è¾¼ã¿
ã¾ãããã«ãããéã®configure
ã®ãªãã·ã§ã³ããµã¼ããã¼ãã£ã¢ã¸ã¥ã¼ã«ã®çµã¿è¾¼ã¿æ¹æ³ããã¡ã¤ã«ã«æ®ããã¨ã§å¾ã
ã®nginxã®æ§æ管çã«å½¹ç«ã¦ããã¨ãã§ãã¾ãã
ããã§ã¯å¿«é©ãªnginxã©ã¤ããã