Full Rails Stack Part 2: Rails, Mongrel and Nginx

We completed setting up ssh and ssh keys in part one, let's continue now with part two of installing a full Rails stack.

SSH into your server:

CODE:
  1. ssh -p 8888 deploy@your_linux_box.com

By default, Debian and Ubuntu have five package repositories called main, restricted, universe, multiverse, and commercial. You will need the universe package repository. By default, it may or may not be enabled. To check, edit the /etc/apt/sources.list file (note that if you didn't install the aliases in part one you'll use "sudo nano" instead of sn below):

CODE:
  1. sn /etc/apt/sources.list

Uncomment the following two lines (assuming Ubuntu Feisty is installed):

CODE:
  1. deb http://us.archive.ubuntu.com/ubuntu/ feisty universe
  2. deb-src http://us.archive.ubuntu.com/ubuntu/ feisty universe

Save and exit nano.

Now, lets make sure our server packages are up to date (note that in all of the installs for our Rails stack if you are prompted with "yes/no" say yes:

CODE:
  1. sudo apt-get update
  2. sudo apt-get upgrade

Install the GCC Tool Chain:

CODE:
  1. sudo apt-get install build-essential

Now lets create a src directory to build from and get ruby and friends setup:

CODE:
  1. cd ~/
  2. mkdir src
  3. cd src
  4. wget ftp://ftp.gnu.org/gnu/readline/readline-5.2.tar.gz
  5. wget ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.6.tar.gz
  6. tar zxvf ruby-1.8.6.tar.gz
  7. tar zxvf readline-5.2.tar.gz
  8. cd readline-5.2
  9. ./configure
  10. make
  11. sudo make install
  12. cd ../ruby-1.8.6
  13. sudo apt-get build-dep ruby1.8
  14. ./configure
  15. make
  16. sudo make install

Install other core packages:

CODE:
  1. sudo apt-get install ri rdoc irb ri1.8 ruby1.8-dev libzlib-ruby zlib1g

Install RubyGems:

CODE:
  1. cd ..
  2. wget http://rubyforge.org/frs/download.php/20989/rubygems-0.9.4.tgz
  3. tar xvzf rubygems-0.9.4.tgz
  4. cd rubygems-0.9.4
  5. sudo ruby setup.rb

Install Ruby on Rails and Dependencies (the following will download the latest framework):

CODE:
  1. sudo gem install rails --include-dependencies --no-rdoc --no-ri

If you need a specific version of rails here is an example which gets version 1.2.5:

CODE:
  1. sudo gem install rails -v 1.2.5 --include-dependencies --no-rdoc --no-ri

Now let's install Mongrel (make sure you select the top ruby option when prompted):

CODE:
  1. sudo gem install mongrel mongrel_cluster --include-dependencies --no-rdoc --no-ri

Now we need to install some packages in preparation for Nginx:

CODE:
  1. sudo apt-get install libpcre3-dev libpcre3 libpcrecpp0 openssl libssl-dev

Grab the latest build of Nginx:

CODE:
  1. cd ~/src
  2. wget http://sysoev.ru/nginx/nginx-0.5.35.tar.gz
  3. tar xzvf nginx-0.5.35.tar.gz
  4. cd nginx-0.5.35
  5. ./configure --sbin-path=/usr/local/sbin --with-http_ssl_module
  6. make
  7. sudo make install

Check that nginx is working and in your $PATH. The version command option should do the trick:

CODE:
  1. nginx -v
  2. nginx version: nginx/0.5.35

That's it for today. Next time we will setup the Nginx configuration files for our website and continue to add new functionality to our stack.

3 Responses to “Full Rails Stack Part 2: Rails, Mongrel and Nginx”


  1. Gravatar Icon 1 Moofius Feb 15th, 2008 at 4:16 pm

    Keep ‘em coming!
    This is great for those who want to learn more about the innerworks of *nix by trying, I’m sure many will appreciate your articles.

  2. Gravatar Icon 2 Anon Mar 3rd, 2008 at 4:56 pm

    Please keep these coming. I’m looking to set up just a site.

  3. Gravatar Icon 3 Andrew Fong Mar 3rd, 2008 at 5:33 pm

    Thank you! It’s been absurdly difficult finding a complete walkthrough for setting up the server from scratch. I normally rely on shared servers for hosting, so my first experience with a VPS was a painful slog through different walkthroughs with different assumptions. I’ve got most everything working, but I still can’t get Postfix to play nice for some reason. Looking forward to more of these!



February 2008
M T W T F S S
« Sep   Mar »
 123
45678910
11121314151617
18192021222324
2526272829  

Categories


Random Photos

  • IMG_0079.JPG
    IMG_1982.JPG
    IMG_1979.JPG
    Sunrise on the way to work


Now Reading

Planned books:

None

Current books:

  • The Consequences of Ideas: Understanding the Concepts that Shaped Our World

    The Consequences of Ideas: Understanding the Concepts that Shaped Our World by R. C. Sproul

  • Born Standing Up

    Born Standing Up by Steve Martin

Recent books:

View full Library