Pages

Thursday, September 12, 2013

Ruby Application Server - Installation notes for Nginx and Passenger

Hi!

Here's how to install Passenger and Nginx. You will get a very fast Ruby application server.

Compile nginx :
tar -xzvf nginx-1.3.14.tar.gz
cd nginx-1.3.14
./configure --prefix=/etc/nginx --with-http_ssl_module

cd /etc/init.d/
ln -snf /etc/nginx/sbin/nginx

Compile passenger :

cd /usr/local/ruby/bin
./passenger-install-nginx-module

 1. Yes: download, compile and install Nginx for me. (recommended)
    The easiest way to get started. A stock Nginx 1.0.6 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: 2

The next step is to point passenger to the source directory. Is this example, the source is in my home folder so it’s -> /home/xxx/nginx-1.3.14.

Than point the installation of nginx to /etc/nginx

Passenger is now installed. Here’s what your nginx config should look like this:
____________________________________________
worker_processes  2;

error_log  logs/error.log  debug;

#pid        logs/nginx.pid;

events {
    worker_connections  2000;
}

http {
    passenger_root /usr/local/ruby-1.8.7-p352/lib/ruby/gems/1.8/gems/passenger-3.0.9;
    passenger_ruby /usr/local/ruby-1.8.7-p352/bin/ruby;
    passenger_max_pool_size 3;

    include       mime.types;
    default_type  application/octet-stream;

    sendfile        on;
    #tcp_nopush     on;

    keepalive_timeout  65;

  server {
     listen 8666;
     server_name localhost;
    
     root /data/opt/local/ruby/myapp/public/;   # <--- be sure to point to 'public'!
     passenger_enabled on;
     passenger_use_global_queue on;

     auth_basic "myapp Access"; # <--- For password auth
     auth_basic_user_file /home/myapp/passwd;
    
   }

     #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
}
______________________________________________________
Start:
/etc/init.d/nginx

Stop :
/etc/init.d/nginx -s stop

No comments:

Post a Comment