LoginSignup
55
57

More than 5 years have passed since last update.

【Linux】Passenger のインストール、Apacheとの連携

Posted at

1. passengerをインストール

$ gem install passenger --no-ri --no-rdoc -V
$ rbenv rehash

2. apacheにpassengerモジュールをインストール

$ passenger-install-apache2-module

※ 必要なソフトウェアがない場合は赤字で知らせてくれるので、インストールしてからもう一度コマンドを実行する。

3. 以下のコマンドを叩くと、apacheとの連携に必要な設定が表示される

$ passenger-install-apache2-module --snippet

LoadModule passenger_module /home/webmaster/.rbenv/versions/2.1.2/lib/ruby/
gems/2.1.0/gems/passenger-4.0.53/buildout/apache2/mod_passenger.so
<IfModule mod_passenger.c>
  PassengerRoot ...
  PassengerDefaultRuby ...
</IfModule>

4. httpd.confを編集

$ sudo vim /etc/httpd/conf/httpd.conf

# 上記の出力メッセージをそのままペースト

# DocumentRootを上書き
DocumentRoot Rails_appのpublicフォルダを指定

# RAILS_ENV変数の設定
RailsEnv 環境名

5. 設定ファイルの文法をチェック

$ apachectl configtest
# Syntax OK と出るはず

6. Apache再起動して、ブラウザでアクセス

$ sudo service httpd restart

Trouble Shooting

「You don’t have permission to access / on this server.」と表示される場合

httpd.confUserGroup項目がきちんとRailsアプリを動かせるユーザ、グループに設定されているか確認

その他

Passengerの実行ユーザ

config.ruの所有者と同じ

55
57
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
55
57