has stabilized # over time. Older versions of nginx (e.g. 0.6.x) requires # "if (!-f $request_filename)" which was less efficient: # http://bogomips.org/unicorn.git/tree/examples/nginx.conf?id=v3.3.1#n127 try_files $uri/index.html $uri.html $uri @app; location @app { # an HTTP header important enough to have its own Wikipedia entry: # http://en.wikipedia.org/wiki/X-Forwarded-For proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; # enable this if and only if you use HTTPS, this helps Rack # set the proper protocol for doing redirects: # proxy_set_header X-Forwarded-Proto https; # pass the Host: header from the client right along so redirects # can be set properly within the Rack application proxy_set_header Host $http_host; # we don't want nginx trying to do something clever with # redirects, we set the Host: header above already. proxy_redirect off; # set "proxy_buffering off" *only* for Rainbows! when doing # Comet/long-poll stuff. It's also safe to set if you're # using only serving fast clients with Unicorn + nginx. # Otherwise you _want_ nginx to buffer responses to slow # clients, really. # proxy_buffering off; proxy_pass http://app_server; } # Rails error pages error_page 500 502 503 504 /500.html; location = /500.html { root /home/seu_usuario/seu_caminho/sua_app/public; } } Os pontos importantes desse arquivo sao: # para definir a porta. listen 8080 default deferred; # definicao do host chamado do navegador. server_name sua_app.local; # caminho estatico da sua app. root /home/seu_usuario/seu_caminho/sua_app/public; Crie um link simbolico em sites-enabled: cd /etc/nginx/sites-enabled/ sudo ln -s /etc/nginx/sites-available/sua_app sua_app Defina o nome da sua app no arquivo hosts: sudo nano /etc/hosts Dentro do arquivo: 127.0.0.1 sua_app.local Start no nginx: sudo /etc/init.d/nginx start Teste o endereco com http://sua_app.local:8080/, vai dar uma mensagem. Vamos instalar o Unicorn. No arquivo Gemfile de sua app, adicione: gem 'unicorn', '3.5.0' Depois rode o 'bundle install' no terminal. Em 'config/' crie um arquivo 'unicorn.rb' e coloque o conteudo abaixo conforme sua maquina: # See http://unicorn.bogomips.org/Unicorn/Configurator.html for complete # documentation. worker_processes 2 # Help ensure your application will always spawn in the symlinked # "current" directory that Capistrano sets up. working_directory "/home/deployer/myapp.com/current" # listen on both a Unix domain socket and a TCP port, # we use a shorter backlog for quicker failover when busy listen "/tmp/myapp.com.sock", :backlog => 64 listen 8080, :tcp_nopush => true # nuke workers after 30 seconds instead of 60 seconds (the default) timeout 30 # feel free to point this anywhere accessible on the filesystem user 'deployer', 'staff' shared_path = "/home/deployer/myapp.com/shared" pid "#{shared_path}/pids/unicorn.pid" stderr_path "#{shared_path}/log/unicorn.stderr.log" stdout_path "#{shared_path}/log/unicorn.stdout.log" Esse e o arquivo default dele encontrado aqui. Para colocar o unicorn em producao e so rodar essa linha no terminal dentro da sua app: unicorn_rails -c config/unicorn.rb -E production -D Para matar ele e so rodar: kill -quit `cat tmp/pids/unicorn.pid` E so isso, bem tranquilo e rapido, se tiver alguma duvida comenta que eu ajudo no que puder. Ate a proxima!!