How To Setup Nginx On Server For Rails Application?


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

Configuration

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

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

configuration file example

server {

listen 80;

server_name http://www.yourdomain.com;

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;

#}

Source : RailsCarma

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s