Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Here's my way of deploying Rails:</p> <ul> <li><strong>Installing Ruby</strong></li> </ul> <p>I would not use RVM because it's very tricky to get it running properly in combination with stuff like cron jobs. Doable (with wrappers for example), but a bit of a hassle. If you don't need other Ruby versions on that machine, just install it from source yourself.</p> <ul> <li><strong>Gems</strong></li> </ul> <p>Just let Bundler work its magic. Remember to install with the flags <code>--without test development --deployment</code>. I wouldn't do that up front though. Just make sure you have bundler.</p> <ul> <li><strong>Web server</strong></li> </ul> <p>Using Passenger (with either Apache or Nginx) is a fine and easy choice. When you install Apache from apt, it will run in a special user.</p> <p>Apache is configured correctly automatically on Ubuntu. It will start on reboot.</p> <ul> <li><strong>Website configuration</strong></li> </ul> <p>All configuration be in /etc/apache2. Place your virtual host configuration in /etc/apache2/sites-available and use <code>a2ensite</code> to enable it.</p> <p>Put your app in <code>/var/www</code>, since that is the default location in Ubuntu. I usually make a deploy user.</p> <p>Make sure that user can access your application by assigning your app to the <code>www-data</code> group.</p> <ul> <li><strong>Database</strong></li> </ul> <p>MySQL has its own user system. Log in as root user and create a new user with SQL: <code>GRANT ALL ON 'application_production'.* TO 'deploy' IDENTIFIED BY 'some password';</code></p> <ul> <li><strong>Assets</strong></li> </ul> <p>Assets should be generated as the user owning the application. You should add any css and javascript files to production.rb. For example:</p> <pre><code>config.assets.precompile += %w(backend.css) </code></pre> <ul> <li><strong>Conclusion</strong></li> </ul> <p>It helps to use a deploy tool like <a href="http://capify.org">Capistrano</a>. When you run <code>capify</code>, uncomment the appropriate line in the <code>Capfile</code> to get assets compilation. Here's mine:</p> <pre><code>ENV['RAILS_ENV'] = 'production' load 'deploy' if respond_to?(:namespace) # cap2 differentiator load 'deploy/assets' load 'config/deploy' require 'capistrano/ext/multistage' require "bundler/capistrano" require 'capistrano_colors' </code></pre> <p>This is just how I normally install my rails apps. I hope this will get you going. Recently I've written a gem for integrating <a href="http://www.opscode.com/chef/">Chef</a>-solo with Capistrano, called <a href="https://github.com/iain/capistrano_chef_solo">capistrano-chef-solo</a>. It's very alpha and might be a bit too complicated if you're just starting with deployment, but it might help you. </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload