LoginSignup
2
2

More than 5 years have passed since last update.

CentOSのデフォルトのApacheで、デフォルトのRubyでmod_mrubyをビルド

Posted at

はじめに

あちこち調べて出てくる情報をつなぎ合わせればどうにかなるけど、そのままトレースできる手順が欲しかった。

環境

# cat /etc/redhat-release
CentOS release 6.6 (Final)

CentOSのRubyが古いので http://blog.hifumi.info/2014/12/04/ngx_mruby-memcached-in-rhel/ を参考に、mod_mrubyビルド用にruby2.1を導入

# cd /usr/local/src
# git clone https://github.com/sstephenson/ruby-build.git
# cd /usr/local/src/ruby-build
# ./install.sh
# ruby-build 2.1.5 /usr/local/ruby21
# ll /usr/local/ruby21
# export PATH=/usr/local/ruby21/bin:$PATH

http://qiita.com/hkusu/items/ca8622c83b0bfc2cac72 を参考にmod_mrubyをビルド&インストール

# yum install httpd-devel
# whereis apxs
# whereis apachectl
# git clone git://github.com/matsumoto-r/mod_mruby.git
# cd mod_mruby/

# cp -p build_config.rb build_config.rb.org
# vim build_config.rb
# diff build_config.rb.org build_config.rb
27c27
<   conf.gem :github => 'matsumoto-r/mruby-redis'
---
>   #conf.gem :github => 'matsumoto-r/mruby-redis'
#
# APXS_PATH_ENV='--with-apxs=/usr/sbin/apxs' APACHECTL_PATH_ENV='--with-apachectl=/usr/sbin/apachectl' sh build.sh
# make install
# apachectl configtest
# service httpd restart
# mkdir /etc/httpd/mruby

# cat /etc/httpd/mruby/test.rb
Apache.echo "Hello World"
# cat /etc/httpd/conf.d/mruby.conf
<Location /mruby>
    mrubyHandlerMiddle /etc/httpd/mruby/test.rb
</Location>

# service httpd restart

ブラウザで http://[IPアドレス]/mruby にアクセス

"Hello World"って表示されればおk

2
2
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
2
2