# mod_mruby extended class conf.gem '../mrbgems/mod_mruby_mrblib'
ビルドしよう!
1
sh build.sh
正常にビルドが終わると、以下のように successful と表示される。
1
*** Warning: Linking the shared library src/mod_mruby.la against the
*** static library ./mruby/build/host/lib/libmruby.a is not portable!
mod_mruby building ... Done
build.sh ... successful
apacheに組み込む。
1
make install
実行結果はこちら
1 2 3 4 5 6 7 8 9
# make install /usr/bin/apxs -i -a -n'mruby' /home/atani/mod_mruby/src/.libs/mod_mruby.so /usr/lib64/httpd/build/instdso.sh SH_LIBTOOL='/usr/lib64/apr-1/build/libtool' /home/atani/mod_mruby/src/.libs/mod_mruby.so /usr/lib64/httpd/modules /usr/lib64/apr-1/build/libtool --mode=install install /home/atani/mod_mruby/src/.libs/mod_mruby.so /usr/lib64/httpd/modules/ libtool: install: install /home/atani/mod_mruby/src/.libs/mod_mruby.so /usr/lib64/httpd/modules/mod_mruby.so Warning! dlname notfoundin /usr/lib64/httpd/modules/mod_mruby.so. Assuming installing a .so rather than a libtool archive. chmod 755 /usr/lib64/httpd/modules/mod_mruby.so [activating module`mruby' in /etc/httpd/conf/httpd.conf]
if geoip.country_code != "JP" Server.return Server::HTTP_FORBIDDEN end
/etc/httpd/conf.d/geo_handler.rb
1 2 3 4 5 6 7 8 9 10 11 12 13 14
Server = get_server_class
r = Server::Request.new c = Server::Connection.new geoip = Userdata.new("geoip_#{Process.pid}").geoip
r.content_type = "text/html" Server.echo"<HEAD><TITLE>your information</TITLE></HEAD><BODY>" Server.echo"Your IP Address is #{c.remote_ip}<br>" Server.echo"Your Country Code is #{geoip.country_code}<br>" Server.echo"Your city is #{geoip.city}<br>" Server.echo"Your region is #{geoip.region}<br>" Server.echo"your are at <a href='http://maps.google.com/maps?q=#{geoip.latitude},#{geoip.longitude}'>this pin</a><br>" Server.echo"</BODY>"
apacheを起動
configtestを行い、問題なければ起動。
1 2 3
# /usr/sbin/apachectl configtest Syntax OK # /usr/sbin/apachectl start
sh:bison: command not found sh:bison: command not found rake aborted! Command Failed: [bison -o "/home/atani/mod_mruby/mruby/build/host/mrbgems/mruby-compiler/core/y.tab.c""/home/atani/mod_mruby/mruby/mrbgems/mruby-compiler/core/parse.y"]
openssl-devel が入ってないと以下のようなエラーとなる。
1 2 3 4 5 6 7 8 9 10
/home/atani/mod_mruby/mruby/build/mrbgems/mruby-digest/src/digest.c:16:25: fatal error: openssl/evp.h: No such file or directory #include <openssl/evp.h> ^ compilation terminated. /home/atani/mod_mruby/mruby/build/mrbgems/mruby-digest/src/digest.c:16:25: fatal error: openssl/evp.h: No such file or directory #include <openssl/evp.h> ^ compilation terminated. rake aborted! Command Failed: [gcc -g -std=gnu99 -O3 -Wall -Werror-implicit-function-declaration -Wdeclaration-after-statement -Wwrite-strings -fPIC -g3 -Wall -Werror-implicit-function-declaration -DMRBGEM_MRUBY_DIGEST_VERSION=0.0.0 -I"/home/atani/mod_mruby/mruby/include" -MMD -o "/home/atani/mod_mruby/mruby/build/host/mrbgems/mruby-digest/src/digest.o" -c "/home/atani/mod_mruby/mruby/build/mrbgems/mruby-digest/src/digest.c"]
GeoIP-devel が入ってないと以下のようなエラーとなる。
1 2 3 4 5 6 7 8 9 10
/home/atani/mod_mruby/mruby/build/mrbgems/mruby-geoip/src/mrb_geoip.c:12:19: fatal error: GeoIP.h: No such file or directory #include <GeoIP.h> ^ compilation terminated. /home/atani/mod_mruby/mruby/build/mrbgems/mruby-geoip/src/mrb_geoip.c:12:19: fatal error: GeoIP.h: No such file or directory #include <GeoIP.h> ^ compilation terminated. rake aborted! Command Failed: [gcc -g -std=gnu99 -O3 -Wall -Werror-implicit-function-declaration -Wdeclaration-after-statement -Wwrite-strings -fPIC -g3 -Wall -Werror-implicit-function-declaration -DMRBGEM_MRUBY_GEOIP_VERSION=0.0.1 -I"/home/atani/mod_mruby/mruby/include" -MMD -o "/home/atani/mod_mruby/mruby/build/host/mrbgems/mruby-geoip/src/mrb_geoip.o" -c "/home/atani/mod_mruby/mruby/build/mrbgems/mruby-geoip/src/mrb_geoip.c"]
httpd-devel が入ってないと以下のようなエラーとなる。
1 2 3 4 5 6 7 8
--with-mruby: https://github.com/mruby/mruby.git will be used. checking for rake1.9.1... no checking for rake... no checking for ruby1.9.1... no checking for ruby... /usr/bin/ruby checking for apxs2... no checking for apxs... no configure: error: neither apxs2 or apxs not found.