views:

363

answers:

3

I have been creating a website with Ruby on Rails, and will be hosting it through a friend. He has the space and capacity to host the server, and I have a system to devote to being a dedicated server. And this is my first attempt at a Rails website, plus self-hosting with a friend.

I will be formatting and preparing the server today and tomorrow with the following software configuration:

  • Apache2
  • Phusion Passenger (aka, mod_rails)
  • Ruby Enterprise Edition
  • MySQL 5

I do have a number of questions, and I apologize for their complexity. I haven't found a guide for this configuration yet, and being new to Rails I haven't the experience to navigate my way through this yet.

What build of Linux is most recommended for this configuration?

I have been planning to deploy on CentOS. The caveat is that I have been a Windows user since my early days, and have only used Linux as a webhost and very few development commands (such as CVS). Thus my knowledge of Linux is rather small, and my experience smaller. If I run into any deployment snags, technicalities thanks to the distro of Linux, or anything of the sort ... I'm totally hung out to dry.

This includes things like building anything from source code.

How do I set up Capistrano on my server for remote deployment?

I know this is an oxymoron (Capistrano is client-side, not server-side) but I don't know what it needs on the server. Does it need FTP? SFTP? SSL? SSH? What?

What do I configure on my server, and how do I configure it, to enable Capistrano to run smoothly?

Also, how do I refer Capistrano to the fact that my SCM is on localhost and is by Mercurial? (I used TortoiseMg.) I could convert to SVN and probably set up a repository on the server, but I'm not entirely sure how to do that.

What is the biggest snag you watch for when deploying from a localhost development, to deployment on a totally different OS?

Miscellaneous

Why not deploy to Windows then? Because I'm footing the bill, and I don't want to pay for another copy of XP or possibly 2000; I refuse to use Vista. Plus, Linux is much more secure than Windows for a server environment.

Why not read the existing guides? I am; this is my first site with Ruby on Rails, my budget is in the less than double-digits area now, and I'm trying to expand my horizons by doing the server configuration and the remote deployment (for further development of the site) by myself. I've relied on hosts in the past for my PHP websites, but they're much more homogeneous in their configuration. Ruby servers are expensive, prohibitively so for me, and to learn its configuration wouldn't hurt to know.

+1  A: 

I've found the articles posted at Slicehost.com (a VPS hosting company) to be pretty helpful.

The full list of articles are at: http://articles.slicehost.com/sitemap . You'll find a number of articles there related to production deployment of a Ruby on Rails application.

Todd
+1  A: 

What build of Linux is most recommended for this configuration?

Any of the distributions will work fine as long as they can run Apache2 (which is almost all of them) and you can install Passenger (along with ruby and rails). I personally use CentOS and find its package manger to be ridiculously easy to use (yum).

yum install -y httpd ruby
gem install rails passenger

Then all you have to do is a little configuration in /etc/httpd/conf/httpd.conf to add Passenger (following the install file for Passenger passenger-install-apache2-module) and point it to your deployment folder .../app_name/current/public.

Since you are using Passenger you should override the restart task to work for it.

config/deploy.rb

namespace :deploy do
  desc "Restart Application"
  task :restart, :roles => :app do
    run "touch #{current_path}/tmp/restart.txt"
  end
end

How do I set up Capistrano on my server for remote deployment?

All Capistrano needs is SSH access with sufficient permissions to deploy, migrate, restart app server, etc. Just follow the getting started guide at the Capistrano website and you will be up and running in no time.

Capistrano needs access to your SCM, you will need to allow it to connect to your machine. All Capistrano does is checkout your code into a release folder and moves the symbolic link from the old version and restarts your app server.

What is the biggest snag you watch for when deploying from a localhost development, to deployment on a totally different OS?

The biggest snag is with migrations, test, test, test, and test them some more. A bug in your application is easy to fix and redeploy, but a bug in your migration could end up a huge pain in the ass with the possibility of data loss.

Samuel
Thanks for the answer Sam. What do you think about making an SVN repository right there on the server? The application is closed-source, and I don't know of any free SVN hosts that permit closed-source hosting.
The Wicked Flea
Making the SVN repository on the server is fine. Let me try to remember where I read about a site that gives you a free private SVN repository.
Samuel
You can check out http://stackoverflow.com/questions/59791/free-online-svn-repositories, I think some of those offer free private SVN.
Samuel
Thanks for your help. :)
The Wicked Flea
A: 

I recommend using Ubuntu server and deprec, as it provides a ton of sysadmin recipes that make things even easier.

Nathan L Smith