[AmazonLinux]へ戻る
= Amazon Linux への Apache Passenger のインストール
まず、gem コマンドで passenger をインストールします。
{{{ code sh
gem install passenger
}}}
== passenger のインストール結果
{{{ code sh
Fetching: daemon_controller-1.2.0.gem (100%)
Successfully installed daemon_controller-1.2.0
Fetching: passenger-4.0.53.gem (100%)
Building native extensions. This could take a while...
Successfully installed passenger-4.0.53
Parsing documentation for daemon_controller-1.2.0
Installing ri documentation for daemon_controller-1.2.0
Parsing documentation for passenger-4.0.53
Installing ri documentation for passenger-4.0.53
Done installing documentation for daemon_controller, passenger after 5 seconds
2 gems installed
}}}
== passenger apache2 モジュールのインストール
次に、passenger の apache2 モジュールをインストールします。
{{{ code sh
passenger-install-apache2-module
}}}
下記のように表示されます。Enter を押下して、続行して下さい。
{{{ code sh
Welcome to the Phusion Passenger Apache 2 module installer, v4.0.53.
This installer will guide you through the entire installation process. It
shouldn't take more than 3 minutes in total.
Here's what you can expect from the installation process:
1. The Apache 2 module will be installed for you.
2. You'll learn how to configure Apache.
3. You'll learn how to deploy a Ruby on Rails application.
Don't worry if anything goes wrong. This installer will advise you on how to
solve any problems.
Press Enter to continue, or Ctrl-C to abort.
}}}
下記のように表示されます。Ruby を選択して Enter を押下することで、続行して下さい。
{{{ code sh
Welcome to the Phusion Passenger Apache 2 module installer, v4.0.53.
This installer will guide you through the entire installation process. It
shouldn't take more than 3 minutes in total.
Here's what you can expect from the installation process:
1. The Apache 2 module will be installed for you.
2. You'll learn how to configure Apache.
3. You'll learn how to deploy a Ruby on Rails application.
Don't worry if anything goes wrong. This installer will advise you on how to
solve any problems.
Press Enter to continue, or Ctrl-C to abort.
--------------------------------------------
Which languages are you interested in?
Use <space> to select.
If the menu doesn't display correctly, press '!'
?・皙◇ Ruby
皙・ Pythonn
皙・ Node.jss
皙・ Meteorr
}}}
== インストール後の Apache の設定例
httpd.conf の末尾に下記の3つの設定を追加します。
Rails を開発モードで動作するようにします。
{{{ code sh
RailsEnv development
}}}
passenger のモジュールをロードします。
{{{ code sh
LoadModule passenger_module /usr/local/share/ruby/gems/2.0/gems/passenger-4.0.53
/buildout/apache2/mod_passenger.so
<IfModule mod_passenger.c>
PassengerRoot /usr/local/share/ruby/gems/2.0/gems/passenger-4.0.53
PassengerDefaultRuby /usr/bin/ruby2.0
</IfModule>
}}}
VirtualHost の設定を追加します。[[BR]]
ec2-user の配下の rails4 ディレクトリをドキュメントルートとし、その下に Rails4 プロジェクト hapo を配置しています。[[BR]]
RailsBaseURI を使用することで、一つのドキュメントルートの中に複数のRails4 プロジェクトが配置できるようになります。
{{{ code sh
<VirtualHost *:80>
ServerName www.yourhost.com
# !!! Be sure to point DocumentRoot to 'public'!
#DocumentRoot /home/ec2-user/rails4/HapoCommunity/public
DocumentRoot /home/ec2-user/rails4
RailsBaseURI /hapo
<Directory /home/ec2-user/rails4/HapoCommunity/public>
Order allow,deny
Allow from all
# This relaxes Apache security settings.
AllowOverride all
# MultiViews must be turned off.
Options -Indexes
Options -MultiViews
</Directory>
</VirtualHost>
}}}