{"id":630,"date":"2011-11-30T21:40:02","date_gmt":"2011-11-30T21:40:02","guid":{"rendered":"http:\/\/41j.com\/blog\/?p=630"},"modified":"2011-11-30T21:40:02","modified_gmt":"2011-11-30T21:40:02","slug":"deploying-a-rails-app-into-a-subdirectory","status":"publish","type":"post","link":"https:\/\/41j.com\/blog\/2011\/11\/deploying-a-rails-app-into-a-subdirectory\/","title":{"rendered":"Deploying a Rails app (into a subdirectory)"},"content":{"rendered":"<p>Some notes on deploying my rails application in to a subdirectory. I&#8217;m using rvm to manage Rails versions and this was all on Debian Lenny.<\/p>\n<p>1. Install Rails (see <a href=\"http:\/\/41j.com\/blog\/2011\/10\/installing-rails-on-ubuntu-10-04-server\/\">here<\/a> for some pointers).<\/p>\n<p>2. Install Passenger<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\ngem install passenger\r\napt-get install apache2-prefork-dev\r\napt-get install libapr1-dev\r\napt-get install libaprutil1-dev\r\npassenger-install-apache2-module        \r\n<\/pre>\n<p>Follow the instructions passenger gives you.<\/p>\n<p>3. Edit your apache config<\/p>\n<p>3.1 Create a symlink to your app&#8217;s public directory inside your current website root:<\/p>\n<p>(in this example my app is call nihongo)<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nln -s \/PATH\/TO\/WEBAPP\/nihongo\/public \/PATH\/TO\/YOUR\/DOCROOT\/nihongo\r\n<\/pre>\n<p>3.1 Edit your apache config for this root to contain a pointer to this app:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nRackBaseURI \/nihongo\r\n&lt;Directory \/PATH\/TO\/YOUR\/DOCROOT\/nihongo&gt;\r\nOptions -MultiViews\r\n&lt;\/Directory&gt;\r\n<\/pre>\n<p>4. Checkout your app&#8230;<\/p>\n<p>Possibly use rake db:setup to setup the database. Use &#8220;bundle install&#8221; to install required bundle files.<\/p>\n<p>Use&#8230;<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nrake assets:precompile\r\n<\/pre>\n<p>to &#8220;compile&#8221; assets, or you may get an error such as:<\/p>\n<pre class=\"brush: ruby; title: ; notranslate\" title=\"\">\r\nCompleted 500 Internal Server Error in 518ms\r\n\r\nActionView::Template::Error (application.css isn't precompiled):\r\n    2: &lt;html&gt;\r\n    3: &lt;head&gt;\r\n    4:   &lt;title&gt;Nihongo&lt;\/title&gt;\r\n    5:   &lt;%= stylesheet_link_tag    &quot;application&quot; %&gt;\r\n    6:   &lt;%= javascript_include_tag &quot;application&quot; %&gt;\r\n    7:   &lt;%= csrf_meta_tags %&gt;\r\n    8: &lt;\/head&gt;\r\n  app\/views\/layouts\/application.html.erb:5:in `_app_views_layouts_application_html_erb___2940450108335557336_39013520'\r\n  app\/controllers\/words_controller.rb:8:in `index'\r\n<\/pre>\n<p>I don&#8217;t quite understand how Rails detects the app is running in production yet. But it does so automatically somehow&#8230;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Some notes on deploying my rails application in to a subdirectory. I&#8217;m using rvm to manage Rails versions and this was all on Debian Lenny. 1. Install Rails (see here for some pointers). 2. Install Passenger gem install passenger apt-get install apache2-prefork-dev apt-get install libapr1-dev apt-get install libaprutil1-dev passenger-install-apache2-module Follow the instructions passenger gives you. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[1],"tags":[],"class_list":["post-630","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p1RRoU-aa","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/41j.com\/blog\/wp-json\/wp\/v2\/posts\/630","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/41j.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/41j.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/41j.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/41j.com\/blog\/wp-json\/wp\/v2\/comments?post=630"}],"version-history":[{"count":1,"href":"https:\/\/41j.com\/blog\/wp-json\/wp\/v2\/posts\/630\/revisions"}],"predecessor-version":[{"id":631,"href":"https:\/\/41j.com\/blog\/wp-json\/wp\/v2\/posts\/630\/revisions\/631"}],"wp:attachment":[{"href":"https:\/\/41j.com\/blog\/wp-json\/wp\/v2\/media?parent=630"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/41j.com\/blog\/wp-json\/wp\/v2\/categories?post=630"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/41j.com\/blog\/wp-json\/wp\/v2\/tags?post=630"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}