Wednesday, March 23, 2011

Installation and deployment for Nginx With Phusion Passenger - Ubuntu 10.x

Installation and deployment for Nginx With Phusion Passenger

Steps to install & deploy for Nginx with Passenger

1. Make sure you have installed Ruby and RubyGems

2. Install passenger gem

   $sudo gem install passenger

3. Check the "passenger-install-nginx-module"

$passenger-

passenger-config                  passenger-make-enterprisey        passenger-status
passenger-install-apache2-module  passenger-memory-stats            passenger-stress-test
passenger-install-nginx-module    passenger-spawn-server

4. Install nginx module

$sudo passenger-install-nginx-module

Welcome to the Phusion Passenger Nginx module installer, v3.0.5.

This installer will guide you through the entire installation process. It
shouldn't take more than 5 minutes in total.

Here's what you can expect from the installation process:

     1. This installer will compile and install Nginx with Passenger support.
     2. You'll learn how to configure Passenger in Nginx.
     3. You'll learn how to deploy a Ruby on Rails application.

Don't worry if anything goes wrong. This installer will advise you on how to
solve any problems.

Press Enter to continue, or Ctrl-C to abort.


5. Checking for required software...

 * GNU C++ compiler... found at /usr/bin/g++
 * The 'make' tool... found at /usr/bin/make
 * A download tool like 'wget' or 'curl'... found at /usr/bin/wget
 * Ruby development headers... found
 * OpenSSL support for Ruby... found
 * RubyGems... found
 * Rake... found at /usr/bin/rake
 * rack... found
 * Curl development headers with SSL support... found
 * OpenSSL development headers... found
 * Zlib development headers... found

--------------------------------------------

Automatically download and install Nginx?

Nginx doesn't support loadable modules such as some other web servers do,
so in order to install Nginx with Passenger support, it must be recompiled.

Do you want this installer to download, compile and install Nginx for you?

      1. Yes: download, compile and install Nginx for me. (recommended)
          The easiest way to get started. A stock Nginx 0.8.54 with Passenger
          support, but with no other additional third party modules, will be
          installed for you to a directory of your choice.

     2. No: I want to customize my Nginx installation. (for advanced users)
         Choose this if you want to compile Nginx with more third party modules
         besides Passenger, or if you need to pass additional options to Nginx's
         'configure' script. This installer will  1) ask you for the location of
         the Nginx source code,  2) run the 'configure' script according to your
         instructions, and  3) run 'make install'.

Whichever you choose, if you already have an existing Nginx configuration file,
then it will be preserved.

Enter your choice (1 or 2) or press Ctrl-C to abort:


if Curl development headers with SSL support was not found abort the process then try this command "sudo apt-get install libcurl4-openssl-dev"

6. Choose 1 then you can see download process finally end with

Where do you want to install Nginx to?

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

press "enter" key if you goahead with default

7. This installer has already modified the configuration file for you! The
following configuration snippet was inserted:

  http {
      ...
      passenger_root /usr/lib/ruby/gems/1.9.1/gems/passenger-3.0.5;
      passenger_ruby /usr/bin/ruby1.9.1;
      ...
  }

After you start Nginx, you are ready to deploy any number of Ruby on Rails
applications on Nginx.


Press ENTER to continue.

8. Deploying a Ruby on Rails application: an example

Suppose you have a Ruby on Rails application in /somewhere. Add a server block
to your Nginx configuration file, set its root to /somewhere/public, and set
'passenger_enabled on', like this:

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

And that's it! You may also want to check the Users Guide for security and
optimization tips and other useful information:

  /usr/lib/ruby/gems/1.9.1/gems/passenger-3.0.5/doc/Users guide Nginx.html

Enjoy Phusion Passenger, a product of Phusion (www.phusion.nl) :-)
http://www.modrails.com/

Phusion Passenger is a trademark of Hongli Lai & Ninh Bui.

Copy the entire server part - "server { ... }"

9. Open nginx config file

   $sudo vim /opt/nginx/conf/nginx.conf


    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

   server {
      listen 80;
      server_name example.com;
      root /home/user/demo;   # <--- be sure to point to 'public'!
      passenger_enabled on;
      rails_env development;
   }


    server {
        listen       80;
        server_name  localhost;

        ....


Add the copied server part after "keepalive_timeout" line

10. Change the "server","root", "rails_env" based on your machine


11. Restart the server by this command

    sudo /opt/nginx/sbin/nginx

   
Hope you may install "Nginx With Phusion Passenger" without any issues by above steps.
 

No comments:

Post a Comment