15.1. Introduction

In the rest of the book, we are always working with the development system. So we start Rails with rails server. Let's have another close look at the output:
$ rails server
=> Booting WEBrick
=> Rails 3.2.6 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2012-07-09 12:19:40] INFO  WEBrick 1.3.1
[2012-07-09 12:19:40] INFO  ruby 1.9.3 (2012-04-20) [x86_64-darwin11.4.0]
[2012-07-09 12:19:40] INFO  WEBrick::HTTPServer#start: pid=86773 port=3000
The second line tells us that we are in "development" mode and that the application can be accessed at the URL http://0.0.0.0:3000. The web server used here is WEBrick (see http://en.wikipedia.org/wiki/Webrick). WEBrick is a very simple HTTP web server and component of the Ruby standard library. But WEBrick is only suitable for development.
For a production system, you would normally use a standard web server such as Apache, lighttpd or Nginx, to serve as reverse proxy and load balancer for the Rails system. The Rails system is then not run by the slow WEBrick, but by more powerful solutions such as Unicorn (http://unicorn.bogomips.org/), Mongrel (http://en.wikipedia.org/wiki/Mongrel_(web_server)), Thin (http://code.macournoyer.com/thin/) or Puma (http://puma.io/).
For a typical PHP project, you can just place the PHP code in a certain directory and in 9 out of 10 cases the available Apache web server can already process PHP code automatically (the corresponding module is almost always installed). With Rails, it's a different story, unfortunately. The obstacles are much bigger and more effort is involved. There is a large number of possible combinations (for example, "Apache, lighttpd or Nginx?" and "Unicorn, Thin, Puma or Mongrel?"). It is impossible to describe all variations in detail here. I decided to pick my favorite combination of Nginx and Unicorn. But that does not mean that other combinations are worse. It's purely a matter of personal choice.

Debian 6

We build our production web server on a minimal Debian 6 system.

Note

This description assumes that you have a freshly installed Debian GNU/Linux 6.0 (Squeeze). You will find an ISO image for the installation at http://www.debian.org/releases/squeeze/debian-installer/. I recommend the approximately 160 MB net installation CD image. For instructions on how to install Debian-GNU/Linux, please go to http://www.debian.org/releases/squeeze/i386/.
We install Ruby 1.9.3 via RVM with the new user deployer. The Rails application we use is called blog.

Important

To carry out this installation, you need to have root rights on the web server!

Updates about this book will be published on my Twitter feed.