LoginSignup
4
5

More than 5 years have passed since last update.

RailsをPassengerを使ってサブディレクトリで動かす

Posted at

大分前に試したので怪しいですが、動作はRails 4.2.0で行ったはず。

Passengerの設定

以下のセットを並べれば複数のアプリケーションを動かすことができる。

/etc/httpd/conf.d/app.conf
Alias /sample /home/mitsui/sample/public
<Location /sample>
    Options Indexes FollowSymLinks
    PassengerAppEnv development
    PassengerBaseURI /sample
    PassengerAppRoot /home/mitsui/sample
</Location>

アセットのプリコンパイル

production環境でやるやつです。RAILS_RELATIVE_URL_ROOTが重要で、たしかこれがないとbootstrap-sassやjquery-ui-railsで利用する画像を/から見にいこうとしてしまい404が返ってくる。

rake assets:precompile RAILS_RELATIVE_URL_ROOT=/sample RAILS_ENV=production
4
5
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
4
5