- 追加された行はこの色です。
- 削除された行はこの色です。
&tag(CentOS6/Apache);
*目次 [#d6b951c8]
#contents
*関連ページ [#h642a494]
-[[Passenger]]
*参考情報 [#vcf1a560]
-[[CentOS6]]
*インストール [#tf006277]
-sakura vpsだと初期状態でインストールされていない。
# yum install httpd
# chkconfig httpd on
-Passengerを使うために以下もインストール。
# yum install http-devel curl-devel
*RVM環境でPassengerを使う [#o27ca633]
-[[RVM環境でRackとPassengerを動かす | Kwappa研究開発室:http://randd.kwappa.net/2010/06/18/175]]
-[[CentOS6にrbenv + ruby + rails + passengerを高速で環境構築(2013年度版) - rksz's lifehack blog:http://rksz.hateblo.jp/entry/2013/02/17_rails_rbenv_passenegr_install]]
**モジュールのインストール [#yeab5ccb]
#pre{{
$ gem install passenger
$ rvmsudo passenger-install-apache2-module
}}
**設定変更 [#bf3724cb]
-/etc/httpd/conf/httpd.confを編集。モジュールインストールの最後で表示された内容をファイルの最後にコピペする。tanaka→ユーザー名。rvmのrubyの名前→インストール時のrvm currentの値となっているはず。
#pre{{
LoadModule passenger_module /home/tanaka/.rvm/gems/ruby-1.9.3-p194@test/gems/passenger-3.0.12/ext/apache2/mod_passenger.so
PassengerRoot /home/tanaka/.rvm/gems/ruby-1.9.3-p194@test/gems/passenger-3.0.12
PassengerRuby /home/tanaka/.rvm/wrappers/ruby-1.9.3-p194@test/ruby
}}
-DocumentRootの設定。とりあえずDocumentRootをrubyアプリのpublicディレクトリに設定する。
DocumentRoot "/var/www/rails/sample/public"
**Rubyアプリの設置 [#q496918a]
-/var/railsに、sampleアプリを設置する。ディレクトリのパーミッションはtanaka.tanaka。パーミッションがおかしいとpermission deniedなんかが表示される。
*rbenv環境でPassengerを使う [#mef1ba93]
-[[CentOS6にrbenv + ruby + rails + passengerを高速で環境構築(2013年度版) - rksz's lifehack blog:http://rksz.hateblo.jp/entry/2013/02/17_rails_rbenv_passenegr_install]]
**モジュールのインストール [#x10596ac]
-passenger-install-apache2-moduleでコケる場合何がたらないか表示してくれるので、たらないものをyumで入れる。
#pre{{
$ gem install passenger
$ passenger-install-apache2-module
}}
-インストール後表示される情報をメモ。
#pre{{
LoadModule passenger_module /home/sora/.rbenv/versions/1.9.3-p429/lib/ruby/gems/1.9.1/gems/passenger-4.0.5/libout/apache2/mod_passenger.so
PassengerRoot /home/sora/.rbenv/versions/1.9.3-p429/lib/ruby/gems/1.9.1/gems/passenger-4.0.5
PassengerDefaultRuby /home/sora/.rbenv/versions/1.9.3-p429/bin/ruby
}}
-さらにこれも必要。
#pre{{
<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>
}}
*トラブルシューティング [#kafbec3c]
**Permission Deniedが表示される [#a7f3d55a]
-CentOSの場合ホームディレクトリのパーミッションを確認する。755に変更しないとApacheはアクセスできない。
-VirtualHostの場合、いきなりRailsのディレクトリを指定せずどこか適当なところを指定すると良い。
**raislの画像が表示されない [#a8e95633]
-railsアプリのトップの画像rails.pngが表示されないのは、production環境におけるconfig.assets.compile=trueにするか、precompileにしないとだめ。[[config.assets.compile=true in Rails production, why not? - Stack Overflow:http://stackoverflow.com/questions/8821864/config-assets-compile-true-in-rails-production-why-not]]