share facebook facebook2 twitter menu hatena pocket slack

2013.03.14 THU

CentOS6にRVM & Passenger & Nginx

鈴木 宏康




# curl -L | bash -s stable


# /usr/local/rvm/bin/rvm install 1.9.3


# rvm use ruby-1.9.3 --default
Using /usr/local/rvm/gems/ruby-1.9.3-p392


# ruby -v
ruby 1.9.3p392 (2013-02-22 revision 39386) [x86_64-linux]


# gem install passenger


# yum -y install gcc gcc-c++ make curl-devel openssl-devel zlib-devel


# cd /usr/local/rvm/src/ruby-1.9.3-p392
# cd ext/openssl/
# ruby extconf.rb
# make
# make install
/usr/bin/install -c -m 0755 /usr/local/rvm/rubies/ruby-1.9.3-p392/lib/ruby/site_ruby/1.9.1/x86_64-linux
installing default openssl libraries


# passenger-install-nginx-module
* GNU C++ compiler... found at /usr/bin/g++
* The 'make' tool... found at /usr/bin/make
* A download tool like 'wget' or 'curl'... found at /usr/bin/curl
* Ruby development headers... found
* OpenSSL support for Ruby... found
* RubyGems... found
* Rake... found at /usr/local/rvm/wrappers/ruby-1.9.3-p392/rake
* rack... found
* Curl development headers with SSL support... found
* OpenSSL development headers... found
* Zlib development headers... found


Automatically download and install Nginx?

Nginx doesn't support loadable modules such as some other web servers do,
so in order to install Nginx with Passenger support, it must be recompiled.

Do you want this installer to download, compile and install Nginx for you?

1. Yes: download, compile and install Nginx for me. (recommended)
The easiest way to get started. A stock Nginx 1.2.6 with Passenger
support, but with no other additional third party modules, will be
installed for you to a directory of your choice.

2. No: I want to customize my Nginx installation. (for advanced users)
Choose this if you want to compile Nginx with more third party modules
besides Passenger, or if you need to pass additional options to Nginx's
'configure' script. This installer will 1) ask you for the location of
the Nginx source code, 2) run the 'configure' script according to your
instructions, and 3) run 'make install'.

Whichever you choose, if you already have an existing Nginx configuration file,
then it will be preserved.

Enter your choice (1 or 2) or press Ctrl-C to abort: 1


# cat /opt/nginx/conf/nginx.conf
http {
passenger_root /usr/local/rvm/gems/ruby-1.9.3-p392/gems/passenger-3.0.19;
passenger_ruby /usr/local/rvm/wrappers/ruby-1.9.3-p392/ruby;

そして、Ruby on Railsを利用する場合は、次のように設定すれば大丈夫なようです。

server {
listen 80;
root /somewhere/public;
passenger_enabled on;


鈴木 宏康

鈴木 宏康

愛知県生まれ。東京工業大学大学院修士課程修了。在学時より、ベンチャー企業でインターネットに関する業務に携わり、現在はクラウド(主にAmazon Web Services)上での開発・運用を軸とした事業の、業務の中心として活躍。