by dontangg on April 4, 2012
I recently setup a Rails server on Ubuntu using Nginx and Unicorn and a database running on the same server using Postgres. I also used rbenv and ruby-build for ruby. I had to look up a lot of information to get this all working. I just wanted to consolidate everything I did into one place. Hopefully, all this can help someone else.
Here are some links to the different parts of this post:
Here are some resources I used to get everything setup the way I wanted:
- Setting up Unicorn with Nginx
- Setting up PostgreSQL on Ubuntu
- Lighting fast, zero-downtime deployments with git, capistrano, nginx and Unicorn
I took my approach from many different places and I’ll explain why I did what I did.
Update – I have since watched a few Railscasts that are very well done and explain most of the same concepts. There are several things that he recommends doing that I will definitely do. He is charging money to see those episodes ($9/month), so I would feel a little guilty posting what I learned here.
Why use these technologies?
Originally, I wanted to host my website on Heroku. Heroku is easy, awesome, and really simple. One web dyno is free and it can scale really easily. For the foreseeable future, however, I will have very low traffic and I want it to be as cheap as possible.
My problem with Heroku came when I realized that I needed more than 5MB of database space. The next tier up gives me 20GB and costs $15/month. This is way more space than I need and costs a lot more than I want to pay.
So, I started looking at VPS hosting since I can get a cheap VPS and have more than 5MB of space for my database, plus I can use it to run jobs if I want, etc. I looked at the cheapest offered solutions at Linode, Dreamhhost, MediaTemple, Amazon, and Rackspace. Rackspace beats them all with 256MB of RAM and 10GB Disk for $11/month + $0.18/GB of bandwidth. I highly doubt that I’ll even use 1GB of bandwidth. Plus, if I do need to scale, it will be really easy to do it with Rackspace Cloud Servers.
Honestly, my main reason for doing my site in Rails is because I love Ruby and Rails is fun to work in.
My reasons are better stated by others:
Since this is for a low traffic site, I went on the word of others. If I was expecting a lot of traffic, I probably would have done more research and some of my own benchmarks. That said, I do feel pretty confident in this setup even though I didn’t do that. Let’s get started!