Sinatra on Nginx on Ubuntu on Passenger

Just wanted to share our setup, as reminder and help for others 😉

(do not forget to create a tmp and public folder inside your projects folder)

server {
  listen 80;

  access_log /var/log/xxx_access.log  main;
  error_log /var/log/xxx_error.log debug;
  root /srv/xxx/public;   # <--- be sure to point to 'public'!
  passenger_use_global_queue on;

require 'app'
disable :run
set :root, Pathname(__FILE__).dirname
run Sinatra::Application

require 'rubygems'
require 'sinatra'

get "/" do
  "Hello world from xxx"

Passenger for Local Development of Multiple Applications on Ubuntu

Starting with the Railscasts episode on passenger I tried to get passenger working for development, since it removes the burden of always starting an extra console for the server and reveals errors that happen in passenger and not in mongel alone.

Apache should use the same group/user you use, otherwise you may get an 302 not allowed error, this can be changed in /etc/apach2/apache2.conf (User / Group).


# /apps is the folder where your projects lie
# I name them all *.lc so i can easily distinguish them from a live application
# if you use subdomains add the *. before the servername (example 1)
<Directory "/apps">
  Order allow,deny
  Allow from all

<Directory "/apps">
  Options FollowSymLinks
  AllowOverride None

<VirtualHost *:80>
  ServerAlias *
  PassengerPoolIdleTime 1800
  RailsEnv development
  DocumentRoot /apps/someproject/public

<VirtualHost *:80>
  PassengerPoolIdleTime 1800
  RailsEnv development
  DocumentRoot /apps/anotherproject/public

hosts file

#/ets/hosts       localhost

restart apache

sudo /etc/init.d/apache2 restart

Hope it works for you 😉