The first step is install nginx with passenger support module. You may choose stable or development version of nginx.
# cd /usr/ports/www/nginx && make config
Step down, find and choose PASSENGER_MODULE option for third-party passenger module,
press OK button and type
# make build install clean
Next step is install www/rubygem-passenger for nginx.
# cd /usr/ports/www/rubygem-passenger && make config
unselect APACHEPORT, then step down and select NGINXPORT.
# make build install clean
Thats all, installation complete.
Add following line to you
/etc/rc.conf
:
nginx_enable="YES"
Write following configuration file for nginx, i.e.
nginx.conf
and put it into /usr/local/etc/nginx
directory.
worker_process 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
passenger_root /usr/local/lib/ruby/gems/1.9/gems/passenger-3.0.11;
passenger_ruby /usr/local/bin/ruby;
passenger_default_user www;
server {
listen 127.0.0.1:80;
server_name localhost;
root /usr/local/lib/ruby/gems/1.9/gems/passenger-3.0.11/test/stub/rack/public;
passenger_enabled on;
passenger_use_global_queue on;
}
}
Save configuration file and start nginx.
# /usr/local/etc/rc.d/nginx start
Here is simple request and the answer from your RoR server:
$ telnet 127.0.0.1 80
GET / HTTP/1.0
HTTP/1.1 200 OK
Content-Type: text/html
Connection: close
Status: 200
X-Powered-By: Phusion Passenger (mod_rails/mod_rack) 3.0.11
Server: nginx/1.0.10 + Phusion Passenger 3.0.11 (mod_rails/mod_rack)
hello worldConnection close by foreign host.
Also, after successfull start nginx and first request you may find following porcesses.
% ps auxww | grep -i passenger
root 72784 0,0 0,1 28112 2932 ?? Is 12:25 0:00,01 PassengerWatchdog
root 72786 0,0 0,1 51704 5224 ?? I 12:25 0:00,04 PassengerHelperAgent
root 72790 0,0 0,2 51924 9764 ?? I 12:25 0:00,06 ruby: Passenger spawn server (ruby)
nobody 72791 0,0 0,1 32476 4500 ?? I 12:25 0:00,01 PassengerLoggingAgent
www 72807 0,0 0,3 56040 11124 ?? I 12:26 0:00,03 ruby: Passenger ApplicationSpawner: /usr/local/lib/ruby/gems/1.9/gems/passenger-3.0.11/test/stub/rack (ruby)
www 72809 0,0 0,3 56064 11180 ?? I 12:26 0:00,00 ruby: Rack: /usr/local/lib/ruby/gems/1.9/gems/passenger-3.0.11/test/stub/rack (ruby)
Комментариев нет:
Отправить комментарий