5
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

How to install Phusion Passenger for Multiple rails app

5
Last updated at Posted at 2014-02-25

サーバ名によって rails アプリを振り分けるために、Phusion Passenger をインストールしました(というか apache の設定をしたと言ったほうがいいのかな)。表記は zsh に準じてますので悪しからず。

Phusion Passenger のインストール

$ sudo `whence gem` install passenger
$ sudo passenger-install-apache2-module
$ sudo `whence passenger-install-apache2-module`

必要なパッケージが足りないと、指示が表示されます。それに従った後、もう一度 passenger-install-apache2-module します。

$ sudo `whence passenger-install-apache2-module`

処理が終わると、/etc/httpd/conf.d/passenger.conf に書くべき内容が表示されます。それを作成します。

LoadModule passenger_module /usr/local/lib/ruby/gems/2.1.0/gems/passenger-4.0.37/buildout/apache2/mod_passenger.so
<IfModule mod_passenger.c>
  PassengerRoot /usr/local/lib/ruby/gems/2.1.0/gems/passenger-4.0.37
  PassengerDefaultRuby /usr/local/bin/ruby
</IfModule>

振り分けの設定

/etc/httpd/conf/httpd.conf の以下の行を有効にします。

NameVirtualHost *:80

/etc/httpd/conf.d/passenger.conf に振り分け設定を追記します。

<VirtualHost *:80>
    ServerName www.app1.com
    DocumentRoot /webapps/app1/public
    SetEnv SECRET_KEY_BASE xxxxxxxxxxxxxx
    <Directory /webapps/app1/public>
        Allow from all
        Options -MultiViews
    </Directory>
</VirtualHost>

<VirtualHost *:80>
    ServerName www.app2.com
    DocumentRoot /webapps/app2/public
    SetEnv SECRET_KEY_BASE xxxxxxxxxxxxxx
    <Directory /webapps/app2/public>
        Allow from all
        Options -MultiViews
    </Directory>
</VirtualHost>

apache の文法チェック

$ apachectl configtest

プリコンパイル済みアセット作成

rails アプリそれぞれについて、プリコンパイル済みアセットを作成します (production 環境だから)。

$ sudo `whence rake` assets:precompile RAILS_ENV=production

httpd 再起動

$ sudo service httpd restart

rails アプリのフォルダ, ファイルには、apache からアクセスできなければなりません。親フォルダのアクセス権もなければなりませんから、気をつけて下さい。


何故かログの出力先が /etc/httpd/logs/error.log になってしまうorz

5
4
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
5
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?