How To Setup Nginx On Server For Rails Application?

Ruby on Rails is a popular rapid development web framework. It allows web designers and developers to quickly implement dynamic and fully featured Ruby on Rails application. This article describes procedures for installing Ruby on Rails in conjunction with the nginx setup and Passenger module.

Nginx (pronounced “engine X”) is a lightweight, high-performance Web server/reverse proxy and e-mail (IMAP/POP3) proxy. It is licensed under a BSD-like license. It runs on UNIX, GNU/Linux, BSD variants, Mac OS X, Solaris, and Microsoft Windows .  Unlike traditional servers, it doesn’t rely on threads to handle requests.

Instead it uses a much more scalable event-driven (asynchronous) architecture. This architecture uses small, but more importantly, predictable amounts of memory under load.

Even if you don’t expect to handle thousands of simultaneous requests, you can still benefit from its’s high-performance and small memory footprint. It scales in all directions: from the smallest VPS all the way up to clusters of servers.

To install nginx you would require passenger first:

Install passenger:

$ gem install passenger

$ passenger -v

In order to let Passenger install it, you need to install a dependency first.

$ sudo apt-get install libcurl4-openssl-dev

use rvmsudo than regular sudo to install it

$rvmsudo passenger-install-nginx-module

start nginx

$ sudo /opt/nginx/sbin/nginx


$ sudo nano /opt/nginx/conf/nginx.conf (VPS)

$ sudo /etc/init.d/nginx reload (VPS)

configuration file example

server {

listen 80;


root /home/Nagakiran/test_app/current/public;

passenger_enabled on;

#charset koi8-r;

#access_log logs/host.access.log main;

#location / {

# root html;

# index index.html index.htm;


Get in touch with us.

Subscribe For Latest Updates

Related Posts

Leave a Comment

Your email address will not be published. Required fields are marked *