How to deploy Rails 3.1 app in a subdirectory

前端 未结 3 1023
轻奢々
轻奢々 2020-12-16 03:43

How do I configure a Rails 3.1 application to run under a specific directory such as \"/r\"?

I tried in config.ru:

map \'/r\' do
    run Debtor::App         


        
相关标签:
3条回答
  • 2020-12-16 03:49

    are you running under passenger?

    Then RailsBaseURI is probably what you want.

    https://www.phusionpassenger.com/library/deploy/apache/deploy/ruby/#deploying-an-app-to-a-sub-uri

    If not running under passenger, please update your question to show what you are deployed under.

    0 讨论(0)
  • 2020-12-16 04:06

    Here’s how to deploy a Rails 3.1 app to a subdirectory in Apache, replacing config.action_controller.relative_url_root which no longer exists.

    In config/routes.rb:

    scope 'my_subdir' do
      # all resources and routes go here
    end
    

    In your Apache configuration file:

    Alias /my_subdir /var/www/my_subdir/public
    <Location /my_subdir>
      SetEnv RAILS_RELATIVE_URL_ROOT "/my_subdir"
      PassengerAppRoot /var/www/my_subdir
    </Location>
    

    And it should work, including automatically pointing all your assets to /my_subdir.

    0 讨论(0)
  • 2020-12-16 04:08

    What worked for me was creating the symbolic link for the sub-uri (/info) to the 'public' folder of the application (setup under another user on my server, /home/otheruser/current/public).

    ln -s /home/myapp/current/public /home/mysite/public_html/info
    

    Then I inserted this configuration inside of the VirtualHost entry for the site:

    Alias /info /home/myapp/current/public
    <Location /info>
      PassengerAppRoot /home/myapp/current
      RackEnv production
      RackBaseURI /info
    </Location>
    

    No scoped routes, no asset prefix configuration.

    0 讨论(0)
提交回复
热议问题