4 steps to install nginx with passenger

Install passenger program that will run your rails application
1. sudo gem install passenger
Install nginx server with passenger enabled
2. passenger-install-nginx-module

it will open apt, click “Enter” to contine
then select option 1 for default install
then it will ask
Where do you want to install Nginx to?

Please specify a prefix directory [/opt/nginx]:
press enter

then copy following block

server {
listen 80;
server_name www.yourhost.com;
root /somewhere/public;   # <— be sure to point to ‘public’!
passenger_enabled on;
}

Make nginx Configuration
3. vi /opt/nginx/conf/nginx.conf
Make passenger_root and passenger_ruby path to configuration

http {
passenger_root /usr/local/lib/ruby/gems/1.8/gems/passenger-2.2.4;
passenger_ruby /usr/local/bin/ruby;

then add server configuration block inside http block
http{

server {
listen 80;
server_name www.yourhost.com; //Make sure this dns entry inside /etc/hosts
root /carsonline/public;   # <— be sure to point to ‘public’! //here carsonline is RAILS_ROOT
passenger_enabled on;
}

Thats, all

4. Launch Server

/opt/nginx/sbin/nginx

Advertisements

About sandipransing

Web Developer #ruby #rails #JS
This entry was posted in Ruby on Rails and tagged , . Bookmark the permalink.

3 Responses to 4 steps to install nginx with passenger

  1. gautamrege says:

    I think passenger_root and passenger_ruby get automatically configured during installation.Good article.

  2. You are right..but sometimes we have to manually configure it when there are multiple ruby installations.

  3. rah00l says:

    Hi Sandip,

    I have recently configured nginx-passenger.
    With the latest version of passenger
    passenger (5.0.7)
    I am able to start nginx and getting default page of nginx saying ..”Welcome to nginx!”

    But I am not sure why definded project is not running with this:

    Though it’s working when I run with “passenger start -e production”

    Find below configurations which i did :

    server {
    listen 80;
    server_name http://www.my-projecttracker.com;
    root /home/rahul/work_space/redmine/public;
    passenger_enabled on;
    rails_env production;
    }

    and

    http {
    passenger_root /home/rahul/.rvm/gems/ruby-1.9.3-p194@my-projecttracker/gems/passenger-5.0.7;
    passenger_ruby /home/rahul/.rvm/wrappers/ruby-1.9.3-p194@my-projecttracker/ruby;

    Can you suggest what I have missed ?

    Advance thanks for yout help…:)

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