Best Practices for New Rails Deployments on Linux

Best practices for new Rails deployments on Linux?

I switched from Mongrel Cluster to Passenger two weeks ago (Debian Linux Server). I didn't look back for a second. Passenger is probably the easiest way to get your new server up and running. Performance and reliability are reasonable too.

Personally, I like to spend my time working on exciting new Rails projects rather than dealing with deployment issues - Passenger enables me to do exactly that. However, Mongrel or something else may still be preferable if you have some kind special requirements (doesn't apply for most products).

Best practices for new Rails deployments on Linux?

I switched from Mongrel Cluster to Passenger two weeks ago (Debian Linux Server). I didn't look back for a second. Passenger is probably the easiest way to get your new server up and running. Performance and reliability are reasonable too.

Personally, I like to spend my time working on exciting new Rails projects rather than dealing with deployment issues - Passenger enables me to do exactly that. However, Mongrel or something else may still be preferable if you have some kind special requirements (doesn't apply for most products).

What is best environment for rails 3 deployment

Nginx + Passenger should be good setup for production.

For long running processes use Nginx + Unicorn.

Ideal Rails Server

Should it use apache or nginx?
Nginx seems to be the preferred route here, unless you need specific Apache features. If you're using Passenger, both Apache and Nginx are supported. More on Passenger here.

Ruby Enterprise Edition or just normal Ruby?
I'm pretty sure REE is only available for Ruby 1.8, which isn't really the preferred version for Rails 3 anymore. Rails 3 had some problems with 1.8, but they might have fixed them by now. Generally, though, Ruby 1.9.2 runs Rails 3 well.

Ideal linux distro?
This really doesn't matter. If you're not sure, Ubuntu is a good choice as there's a lot of knowledge out there, and it's pretty easy to use. Slicehost has a bunch of great articles on getting started with a VPS, and a lot of them focus specifically on Ubuntu: http://articles.slicehost.com/.

MySQL, PostgreSQL or something else?
This is definitely subjective. MySQL is definitely the most common out there, and if you're really unsure, it's a good starting point. However, people often argue that PostgreSQL is cleaner and easier to use that MySQL. If you're just starting, I would recommend MySQL just because of the amount of information out there already.

How should the directories be laid out (where to put your rails sites or anything else)?
You can put your rails project anywhere you like, so I like to just put it in my home directory. Just make sure that your web server has access to your static assets.

Deployment options?
Capistrano is popular. You just commit your changes and cap deploy, and you'll be up and running.

Anything else?
If this all seems overwhelming, look into a simpler solution like Heroku. They set everything up for you, and, while you loose some flexibility, you won't have to worry about any of this. Their pricing isn't too bad, and they offer a free option.

Ruby on Rails: How to deploy an app on remote linux server

The process of setting up your production server will be pretty much the same as with setting up your development machine in terms of installing Ruby and its dependencies. There are no binaries that you can just copy over. In addition to that you'll have to install and set up a web server like Apache or nginx.

I recommend this guide by Digital Ocean. It goes through everything from installing ruby, to setting up the database, to configuring the web server.

They have a couple more (here and here), which seem to be very similar, using different application and web servers, but I haven't read them.

What deployment directories do you use for Rails applications (deploying to a debian box)?

As other people have said, it really doesn't matter where you keep your applications - the thing that does matter is that you're consistent about it, so that whichever server you're on, its just a case of going to the usual location.

I think the only reason people use /u/apps/#{appname} is that it's Capistrano's default setting - certainly it seems odd to me doing things that way.

Deploying a RoR website on a linux machine

  1. Capistrano, which is popular in the RoR community, uses /u/apps/your_app/current where current is a symlink to a timestamp directory with the latest version of the source code. That's as reasonable a place as any, although I prefer /var/www/your_app. See this diagram. https://raw.github.com/mpasternacki/capistrano-documentation-support-files/master/default-execution-path/Capistrano%20Execution%20Path.jpg

  2. leave it where RoR has it by default, under your rails application root

  3. By default I use 570 (r-xrwx---) for directories and 460 (r--rw-----) for files with the owner set to www-data, which is the user my web server (nginx) and app server (RoR) execute as. I set the group to a group called webadmin and add my login to that group so I can deploy and make changes. If your app needs to write to any files or directories, add write permission to specific files/directories on an as-needed basis.



Related Topics



Leave a reply



Submit