リバースプロキシに利用しているNginx。
この度Nginx1.2.0-1がリリースされました。
軽量で高速なHTTPサーバ、「NGINX 1.2」公開
この1.2.0-1にConsistentHashingしてバックエンドにリクエストを分散出来るようにする
HttpUpstreamConsistentHashモジュールを追加しつつrpm化したのでメモ。
ビルド環境
OS | CentOS 5.8 x86_64 |
---|---|
nginx | nginx-1.2.0-1.el5.ngx.src.rpm |
『HttpUpstreamConsistentHash』モジュールを任意のディレクトリにclone
cd /usr/local/src/ git clone git://github.com/replay/ngx_http_consistent_hash.git
src.rpmをダウンロードしてspecファイルを編集
[tsunokawa@test ~]$ wget http://nginx.org/packages/centos/5/SRPMS/nginx-1.2.0-1.el5.ngx.src.rpm [tsunokawa@test ~]$ rpm -ivh nginx-1.2.0-1.el5.ngx.src.rpm [tsunokawa@test ~]$ [tsunokawa@test ~]$ cd /usr/src/redhat/SPECS/ [tsunokawa@test ~]$ vi nginx.spec
specファイルを以下のようにコンパイルオプションに『HttpUpstreamConsistentHash』モジュールを含めるように追加
./configure \ --prefix=%{_sysconfdir}/nginx/ \ --sbin-path=%{_sbindir}/nginx \ --conf-path=%{_sysconfdir}/nginx/nginx.conf \ (略) --add-module=/usr/local/src/ngx_http_consistent_hash \
specファイルからrpmbuild
[tsunokawa@test ~]$ rpmbuild -bb nginx.spec
するとmakeでエラーになる。
↓こんなエラー
(略) + make -j2 make -f objs/Makefile make[1]: Entering directory `/usr/src/redhat/BUILD/nginx-1.2.0' gcc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Wunused-function -Wunused-variable -Wunused-value -Werror -g -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \ -o objs/src/core/nginx.o \ src/core/nginx.c gcc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Wunused-function -Wunused-variable -Wunused-value -Werror -g -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \ -o objs/src/core/ngx_log.o \ src/core/ngx_log.c cc1: warnings being treated as errors src/core/ngx_log.c: In function 'ngx_error_log': src/core/ngx_log.c:429: warning: unused parameter 'cmd' src/core/ngx_log.c:429: warning: unused parameter 'conf' make[1]: *** [objs/src/core/ngx_log.o] Error 1 make[1]: *** Waiting for unfinished jobs.... cc1: warnings being treated as errors src/core/nginx.c: In function 'ngx_set_user': src/core/nginx.c:1110: warning: unused parameter 'cmd' src/core/nginx.c: In function 'ngx_set_env': src/core/nginx.c:1173: warning: unused parameter 'cmd' src/core/nginx.c: In function 'ngx_set_priority': src/core/nginx.c:1203: warning: unused parameter 'cmd' src/core/nginx.c: In function 'ngx_set_cpu_affinity': src/core/nginx.c:1243: warning: unused parameter 'cmd' make[1]: *** [objs/src/core/nginx.o] Error 1 make[1]: Leaving directory `/usr/src/redhat/BUILD/nginx-1.2.0' make: *** [build] Error 2 error: Bad exit status from /var/tmp/rpm-tmp.9291 (%build) RPM build errors: Bad exit status from /var/tmp/rpm-tmp.9291 (%build)
『CentOS5.5 x86_64 で 最新のnginx を rpmbuildする』
http://d.hatena.ne.jp/kopug/20100918
こちらを参考にさせて頂いて、
nginx.specの
%build
の下に
export LANG='ja_JP.UTF-8'
を追記する。
↓こんな感じ
%build export LANG='ja_JP.UTF-8' ./configure \ --prefix=%{_sysconfdir}/nginx/ \
で、もう一度specファイルからrpmbuild
[tsunokawa@test ~]$ rpmbuild -bb nginx.spec
完了
[tsunokawa@test ~]$ ls -la /usr/src/redhat/RPMS/x86_64/ total 8 drwxr-xr-x 2 root root 4096 Apr 26 00:00 . drwxr-xr-x 4 root root 4096 Apr 4 00:00 .. -rw-r--r-- 1 root root 328683 Apr 26 00:00 nginx-1.2.0-1.ngx.x86_64.rpm