6
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

nginxとngx_mrubyのrpmパッケージを作成する

Last updated at Posted at 2014-11-18

環境はCentOS6.6です

mruby-redis依存のhiredisをリビルドしてインストール

$ wget http://ftp.riken.jp/Linux/fedora/releases/20/Everything/source/SRPMS/h/hiredis-0.11.0-3.fc20.src.rpm
$ rpm -ivh hiredis-0.11.0-3.fc20.src.rpm
$ rpmbuild -ba ~/rpmbuild/SPECS/hiredis.spec
$ sudo yum localinstall ~/rpmbuild/RPMS/x86_64/hiredis-0.11.0-3.el6.x86_64.rpm ~/rpmbuild/RPMS/x86_64/hiredis-devel-0.11.0-3.el6.x86_64.rpm

SOURCESディレクトリ配下にngx_mrubyのtarballを作成する
バージョンは現在の最新1.6.6を指定

$ cd ~/rpmbuild/SOURCES/
$ git clone https://github.com/matsumoto-r/ngx_mruby.git ngx_mruby-1.6.6
$ cd ngx_mruby-1.6.6
$ git submodule init
$ git submodule update
$ cd ..
$ tar cvfz ngx_mruby-1.6.6.tar.gz ngx_mruby-1.6.6

nginx公式からsrpmを持ってきてリビルドの準備

$ cd ~
$ wget http://nginx.org/packages/centos/6/SRPMS/nginx-1.6.2-1.el6.ngx.src.rpm
$ rpm -ivh nginx-1.6.2-1.el6.ngx.src.rpm

specファイルを下記の感じで書き換える

@@ -42,12 +42,18 @@
 Requires(pre): pwdutils
 %endif

+%define ngx_mruby_var 1.6.6
+Requires: hiredis
+BuildRequires: git
+BuildRequires: ruby-devel
+BuildRequires: hiredis-devel
+
 # end of distribution specific definitions

 Summary: High performance web server
 Name: nginx
 Version: 1.6.2
-Release: 1%{?dist}.ngx
+Release: 1%{?dist}.mruby
 Vendor: nginx inc.
 URL: http://nginx.org/

@@ -61,6 +67,7 @@
 Source7: nginx.suse.init
 Source8: nginx.service
 Source9: nginx.upgrade.sh
+Source10: ngx_mruby-%{ngx_mruby_var}.tar.gz

 License: 2-clause BSD-like license

@@ -82,11 +89,20 @@
 Not stripped version of nginx built with the debugging log support.

 %prep
-%setup -q
+%setup -a 10 -q

 %build
+
+cd %{_builddir}/%{name}-%{version}/ngx_mruby-%{ngx_mruby_var}/
+./configure --with-ngx-src-root=%{_builddir}/%{name}-%{version}/
+make build_mruby
+make generate_gems_config
+
+cd %{_builddir}/%{name}-%{version}/
 ./configure \
         --prefix=%{_sysconfdir}/nginx \
+        --add-module=./ngx_mruby-%{ngx_mruby_var}/ \
+        --add-module=./ngx_mruby-%{ngx_mruby_var}/dependence/ngx_devel_kit \
         --sbin-path=%{_sbindir}/nginx \
         --conf-path=%{_sysconfdir}/nginx/nginx.conf \
         --error-log-path=%{_localstatedir}/log/nginx/error.log \
@@ -126,6 +142,8 @@
         %{_builddir}/%{name}-%{version}/objs/nginx.debug
 ./configure \
         --prefix=%{_sysconfdir}/nginx \
+        --add-module=./ngx_mruby-%{ngx_mruby_var}/ \
+        --add-module=./ngx_mruby-%{ngx_mruby_var}/dependence/ngx_devel_kit \
         --sbin-path=%{_sbindir}/nginx \
         --conf-path=%{_sysconfdir}/nginx/nginx.conf \
         --error-log-path=%{_localstatedir}/log/nginx/error.log \

必要モジュールをインストールしてリビルドする

$ sudo yum-builddep ~/rpmbuild/SPECS/nginx.mruby.spec
$ rpmbuild -ba ~/rpmbuild/SPECS/nginx.mruby.spec

これでビルドできましたが、
まだうごかしてません!
次は動かします

追記

この記事で作ったものです
http://packages.bitbucket.org/centos/6/rpms/nginx-1.6.2-1.el6.mruby.x86_64.rpm
http://packages.bitbucket.org/centos/6/rpms/hiredis-0.11.0-3.el6.x86_64.rpm
http://packages.bitbucket.org/centos/6/srpms/nginx-1.6.2-1.el6.mruby.src.rpm

6
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?