cubicdaiya / mruby_nginx_module

Embed mruby into nginx
http://cubicdaiya.github.io/mruby_nginx_module
Other
34 stars 5 forks source link

mruby module for nginx Build Status

Summary

mruby_nginx_module is the powerful extension by mruby for nginx.

Concept

The concept of mruby_nginx_module is following.

Examples

location /mruby {
    mruby_content_handler_code "
        sum = 0
        (1..10).each { |i| sum += i }
        Nginx.rputs(sum.to_s + "\n") #=> 55
    ";
}

How to use

Please see Documents.

Dependencies

Minumum Require

Optional

Build

Minumum Require

mruby+mruby_nginx_module

$ git clone https://github.com/cubicdaiya/mruby_nginx_module.git
$ cd mruby_nginx_module
$ git submodule update --init
$ cd mruby
$ # Optional commands if you want
$ rake ENABLE_GEMS="true" CFLAGS="-O2 -fPIC"

nginx+mruby_nginx_module

$ # download and unpack stable nginx version
$ cd nginx-1.4.1 # for eaxmple
$ ./configure -add-module=../mruby_nginx_module
$ make
$ sudo make install

Optional commands

mruby+mgem

$ gem install mgem
$ mgem update && mgem list 
$ mgem add mruby-userdata # for example
$ mgem active mruby-userdata
$ mgem config # answer the question and then you should add this 
$ # replcae build_config.rb with last text output or make changes by hand, then
$ rake ENABLE_GEMS="true" CFLAGS="-O2 -fPIC" 

+nginx-echo-module+ngx_devel_kit

$ # download and unpack stable nginx version
$ cd nginx-1.4.1 # for eaxmple
$ ./configure --with-pcre-jit --add-module=../nginx-echo-module \
--add-module=../mruby_nginx_module --add-module=../ngx_devel_kit
$ make
$ sudo make install

Run test

$ cd mruby_nginx_module
rake NGINX_BIN=#{nginx_bin}

Pass all tests - echo-nginx-module is requierd. Make sure where nginx placed Default NGINX_BIN is /usr/sbin/nginx. Change it if diferent in mruby_nginx_module/test/test.rb

Difference between ngx_mruby

mruby_nginx_module is forked from ngx_mruby at July 2013.

Though I used to develop ngx_mruby with ngx_mruby's developers, what I want to develop were gradually departured from what they want to develop.

What I want to develop are as previously noted concepts.

ngx_mruby is a part of unified web server extension developing support institution(like mod_mruby).

But what I want to develop is the product that is more specialized for nginx.

In detail, mruby_nginx_modules has the following features currently.

Additionally I'm going to implement the following features.