• Showing Page History #100058

AmazonLinuxへ戻る

Amazon Linux への Apache Passenger のインストール

まず、gem コマンドで passenger をインストールします。

  1. gem install passenger

passenger のインストール結果

  1. Fetching: daemon_controller-1.2.0.gem (100%)
  2. Successfully installed daemon_controller-1.2.0
  3. Fetching: passenger-4.0.53.gem (100%)
  4. Building native extensions. This could take a while...
  5. Successfully installed passenger-4.0.53
  6. Parsing documentation for daemon_controller-1.2.0
  7. Installing ri documentation for daemon_controller-1.2.0
  8. Parsing documentation for passenger-4.0.53
  9. Installing ri documentation for passenger-4.0.53
  10. Done installing documentation for daemon_controller, passenger after 5 seconds
  11. 2 gems installed

passenger apache2 モジュールのインストール

次に、passenger の apache2 モジュールをインストールします。

  1. passenger-install-apache2-module

下記のように表示されます。Enter を押下して、続行して下さい。

  1. Welcome to the Phusion Passenger Apache 2 module installer, v4.0.53.
  2. This installer will guide you through the entire installation process. It
  3. shouldn't take more than 3 minutes in total.
  4. Here's what you can expect from the installation process:
  5. 1. The Apache 2 module will be installed for you.
  6. 2. You'll learn how to configure Apache.
  7. 3. You'll learn how to deploy a Ruby on Rails application.
  8. Don't worry if anything goes wrong. This installer will advise you on how to
  9. solve any problems.
  10. Press Enter to continue, or Ctrl-C to abort.

下記のように表示されます。Ruby を選択して Enter を押下することで、続行して下さい。

  1. Welcome to the Phusion Passenger Apache 2 module installer, v4.0.53.
  2. This installer will guide you through the entire installation process. It
  3. shouldn't take more than 3 minutes in total.
  4. Here's what you can expect from the installation process:
  5. 1. The Apache 2 module will be installed for you.
  6. 2. You'll learn how to configure Apache.
  7. 3. You'll learn how to deploy a Ruby on Rails application.
  8. Don't worry if anything goes wrong. This installer will advise you on how to
  9. solve any problems.
  10. Press Enter to continue, or Ctrl-C to abort.
  11. --------------------------------------------
  12. Which languages are you interested in?
  13. Use <space> to select.
  14. If the menu doesn't display correctly, press '!'
  15. ?・皙◇ Ruby
  16. 皙・ Pythonn
  17. 皙・ Node.jss
  18. 皙・ Meteorr

インストール後の Apache の設定例

httpd.conf の末尾に下記の3つの設定を追加します。

Rails を開発モードで動作するようにします。

  1. RailsEnv development

passenger のモジュールをロードします。

  1. LoadModule passenger_module /usr/local/share/ruby/gems/2.0/gems/passenger-4.0.53
  2. /buildout/apache2/mod_passenger.so
  3. <IfModule mod_passenger.c>
  4. PassengerRoot /usr/local/share/ruby/gems/2.0/gems/passenger-4.0.53
  5. PassengerDefaultRuby /usr/bin/ruby2.0
  6. </IfModule>

VirtualHost の設定を追加します。
ec2-user の配下の rails4 ディレクトリをドキュメントルートとし、その下に Rails4 プロジェクト hapo を配置しています。
RailsBaseURI を使用することで、一つのドキュメントルートの中に複数のRails4 プロジェクトが配置できるようになります。

  1. <VirtualHost *:80>
  2. ServerName www.yourhost.com
  3. DocumentRoot /home/ec2-user/rails4
  4. RailsBaseURI /hapo
  5. <Directory /home/ec2-user/rails4/HapoCommunity/public>
  6. Order allow,deny
  7. Allow from all
  8. # This relaxes Apache security settings.
  9. AllowOverride all
  10. # MultiViews must be turned off.
  11. Options -Indexes
  12. Options -MultiViews
  13. </Directory>
  14. </VirtualHost>