Setting up an nginx based rails stack on ubuntu

Overview

We'll be installing a full rails stack without apache on ubuntu dapper:

Make sure you download the latest version of nginx, ruby and the other components. Don't just blindly copy/paste the code snippets or your precious rails stack will be obsolete in a New York minute.

Okay, let's get messy.

Preparations

Start by enabling the Ubuntu Universe repository and updating your package sources:

sudo nano /etc/apt/sources.list

Uncomment the lines containing 'universe'. Save and exit.

Update the package sources:

sudo apt-get update

MySQL and friends

sudo apt-get install mysql-server mysql-common mysql-client libmysqlclient15-dev libmysqlclient15off

sudo mysqladmin -u root password newrootsqlpassword

sudo apt-get install libmysql-ruby

GCC compilers and dev tools.

sudo apt-get install build-essential libpcre3-dev

Ruby and friends

sudo apt-get install ruby1.8-dev ruby1.8 ri1.8 rdoc1.8 irb1.8 libreadline-ruby1.8 libruby1.8 libopenssl-ruby

sudo ln -s /usr/bin/ruby1.8 /usr/local/bin/ruby
sudo ln -s /usr/bin/ri1.8 /usr/local/bin/ri
sudo ln -s /usr/bin/rdoc1.8 /usr/local/bin/rdoc
sudo ln -s /usr/bin/irb1.8 /usr/local/bin/irb
  • On ubuntu dapper, you'll have to install the ruby gems system by downloading it from sourceforge and running ./setup.rb.
  • On ubuntu edgy, you can just install ruby gems with apt-get.

Mongrel and mongrel_cluster

sudo gem install daemons gem_plugin mongrel mongrel_cluster --include-dependencies

Rails

sudo gem install rails --include-dependencies

ImageMagick

sudo apt-get install libxml2-dev libmagick9-dev imagemagick
sudo gem install rmagick

Nginx

Download nginx into a temp directory, unpack and install:

wget http://sysoev.ru/nginx/nginx-0.5.14.tar.gz
tar -xzvf nginx-0.5.14.tar.gz
cd nginx-0.5.14
./configure --sbin-path=/usr/local/sbin
make
sudo make install
sudo chmod +x /usr/local/sbin/nginx

All done. Have fun.

 

Comments