Step by Step Ruby on Rails

Ruby on Railsで実際にWebサイトを構築する手順をまとめています。

Phusion PassengerをRubyGemsでインストール

Phusion PassengerをrootアカウントでRubyGemsでインストールした際の手順をメモ書きしています。
 
1)passengerをインストール
 

# gem install passenger
 
Successfully installed fastthread-1.0.7
Successfully installed daemon_controller-1.1.1
Successfully installed passenger-3.0.19

 
2)"passenger-install-apache2-module"を実行
 

# passenger-install-apache2-module
 
Checking for required software...
・・・
Some required software is not installed.
But don't worry, this installer will tell you how to install them.

Press Enter to continue, or Ctrl-C to abort.

--------------------------------------------

Installation instructions for required software

 * To install Curl development headers with SSL support:
   Please run yum install curl-devel as root.

 * To install OpenSSL development headers:
   Please run yum install openssl-devel as root.

 * To install Zlib development headers:
   Please run yum install zlib-devel as root.

 * To install Apache 2 development headers:
   Please run yum install httpd-devel as root.

 * To install Apache Portable Runtime (APR) development headers:
   Please run yum install apr-devel as root.

 * To install Apache Portable Runtime Utility (APU) development headers:
   Please run yum install apr-util-devel as root.

依存性をチェックし、必要なソフトウェアとインストール方法が表示されます。
 
3)不足ソフトウェアをインストール
 
①curl-develをインストール

# yum install curl-devel
 
Installed:
  libcurl-devel.x86_64 0:7.19.7-26.el6_2.4

Dependency Installed:
  autoconf.noarch 0:2.63-5.1.el6         automake.noarch 0:1.11.1-1.2.el6
  libidn-devel.x86_64 0:1.18-2.el6

Dependency Updated:
  curl.x86_64 0:7.19.7-26.el6_2.4       libcurl.x86_64 0:7.19.7-26.el6_2.4

Complete!

 
②openssl-develをインストール

# yum install openssl-devel
 
Installed:
  openssl-devel.x86_64 0:1.0.0-25.el6_3.1

Dependency Installed:
  keyutils-libs-devel.x86_64 0:1.4-4.el6
  krb5-devel.x86_64 0:1.9-33.el6_3.3
  libcom_err-devel.x86_64 0:1.41.12-12.el6
  libselinux-devel.x86_64 0:2.0.94-5.3.el6
  libsepol-devel.x86_64 0:2.0.41-4.el6
  zlib-devel.x86_64 0:1.2.3-27.el6

Dependency Updated:
  e2fsprogs.x86_64 0:1.41.12-12.el6
  e2fsprogs-libs.x86_64 0:1.41.12-12.el6
  keyutils-libs.x86_64 0:1.4-4.el6
  krb5-libs.x86_64 0:1.9-33.el6_3.3
  libcom_err.x86_64 0:1.41.12-12.el6
  libselinux.x86_64 0:2.0.94-5.3.el6
  libselinux-utils.x86_64 0:2.0.94-5.3.el6
  libss.x86_64 0:1.41.12-12.el6
  openssl.x86_64 0:1.0.0-25.el6_3.1

Complete!

 
③zlib-develをインストール

# yum install zlib-devel
 
Package zlib-devel-1.2.3-27.el6.x86_64 already installed and latest version
Nothing to do

 
④httpd-develをインストール

# yum install httpd-devel

Installed:
  httpd-devel.x86_64 0:2.2.15-15.el6.centos.1

Dependency Installed:
  apr-devel.x86_64 0:1.3.9-5.el6_2
  apr-util-devel.x86_64 0:1.3.9-3.el6_0.1
  cyrus-sasl-devel.x86_64 0:2.1.23-13.el6_3.1
  db4-cxx.x86_64 0:4.7.25-17.el6
  db4-devel.x86_64 0:4.7.25-17.el6
  expat-devel.x86_64 0:2.0.1-11.el6_2
  nss-tools.x86_64 0:3.13.6-2.el6_3
  openldap-devel.x86_64 0:2.4.23-26.el6_3.2

Dependency Updated:
  cyrus-sasl.x86_64 0:2.1.23-13.el6_3.1
  cyrus-sasl-lib.x86_64 0:2.1.23-13.el6_3.1
  db4.x86_64 0:4.7.25-17.el6
  db4-utils.x86_64 0:4.7.25-17.el6
  expat.x86_64 0:2.0.1-11.el6_2
  nspr.x86_64 0:4.9.2-0.el6_3.1
  nss.x86_64 0:3.13.6-2.el6_3
  nss-sysinit.x86_64 0:3.13.6-2.el6_3
  nss-util.x86_64 0:3.13.6-1.el6_3
  openldap.x86_64 0:2.4.23-26.el6_3.2

Complete!

 
⑤apr-develをインストール

# yum install apr-devel
 
Package apr-devel-1.3.9-5.el6_2.x86_64 already installed and latest version
Nothing to do

 
⑥apr-util-develをインストール

# yum install apr-util-devel
 
Package apr-util-devel-1.3.9-3.el6_0.1.x86_64 already installed and latest version
Nothing to do

 
4)再度、passenger-install-apache2-moduleを実行
 

# passenger-install-apache2-module

--------------------------------------------
The Apache 2 module was successfully installed.

Please edit your Apache configuration file, and add these lines:

   LoadModule passenger_module /usr/lib64/ruby/gems/1.8/gems/passenger-3.0.19/ext/apache2/mod_passenger.so
   PassengerRoot /usr/lib64/ruby/gems/1.8/gems/passenger-3.0.19
   PassengerRuby /usr/bin/ruby

After you restart Apache, you are ready to deploy any number of Ruby on Rails
applications on Apache, without any further Ruby on Rails-specific
configuration!

Press ENTER to continue.


--------------------------------------------
Deploying a Ruby on Rails application: an example

Suppose you have a Rails application in /somewhere. Add a virtual host to your
Apache configuration file and set its DocumentRoot to /somewhere/public:

   <VirtualHost *:80>
      ServerName www.yourhost.com
      # !!! Be sure to point DocumentRoot to 'public'!
      DocumentRoot /somewhere/public
      <Directory /somewhere/public>
         # This relaxes Apache security settings.
         AllowOverride all
         # MultiViews must be turned off.
         Options -MultiViews
      </Directory>
   </VirtualHost>

And that's it! You may also want to check the Users Guide for security and
optimization tips, troubleshooting and other useful information:

  /usr/lib64/ruby/gems/1.8/gems/passenger-3.0.19/doc/Users guide Apache.html

Enjoy Phusion Passenger, a product of Phusion (www.phusion.nl) :-)
https://www.phusionpassenger.com

Phusion Passenger is a trademark of Hongli Lai & Ninh Bui.

インストール後、設定方法とデプロイ方法も記載されます。