How to Set Up a Sinatra App Under Apache with Passenger

How do I set up a Sinatra app under Apache with Passenger?

Basic directory structure:

app
|-- config.ru # <- rackup file
|-- hello-app.rb # <- your application
|-- public/ # <- static public files (passenger needs this)
`-- tmp/
`-- restart.txt # <- touch this file to restart app

Virtual host file:

<VirtualHost *:80>
ServerName app.example.com
DocumentRoot /path/to/app/public
<Directory /path/to/app/public>
Order allow,deny
Allow from all
</Directory>
</VirtualHost>

config.ru

# encoding: UTF-8
require './hello-app'
run Sinatra::Application

hello-app.rb (sample application):

#!/usr/bin/env ruby
# encoding: UTF-8
require 'rubygems' # for ruby 1.8
require 'sinatra'

get '/hi' do
"Hello World!"
end

restart.txt is empty.


Mildly useful links:

  • Heroku rack documentation
  • Phusion Passenger documentation

Not able to serve my sinatra app with passenger/apache

Change DocumentRoot "/var/www/html/billomatic" to DocumentRoot "/var/www/html/billomatic/public"

and <Directory "/var/www/html/billomatic"> to <Directory "/var/www/html/billomatic/public">

Ruby, Sinatra and Passenger config on Apache

The new issue with the nil class was due to not finalizing the classes properly. I needed to add the following after the models were loaded:

DataMapper.finalize

Thanks to @Frost for his continued help within the comments.

Setting up Sinatra with RVM & Apache (passenger)

  • Deploying a Rack based Ruby application (from Passenger for Apache docs)
  • RVM Passenger integration (from the RVM site)

Basically, Passenger 3 uses the RVM settings that were in effect when the installer was run as its default Ruby. In other words, if you installed RVM with 1.9.2 before installing Passenger, Passenger should be using RVM's 1.9.2 Ruby automagically. Just make a config.ru and vhost as described is the Passenger docs.

How to configure VirtualHost for a Sinatra App with Passenger?

It seems OK,are the priviledges set correctly?

deploy a sinatra app with passenger gives only 404, page not founds. Yet a simple rack app works

You are not loading the routes in app.rb. To do this, replace require 'sinatra' with require File.join(File.dirname(__FILE__), 'app.rb') in config.ru.

root_dir = File.dirname(__FILE__)
app_file = File.join(root_dir, 'app.rb')
require app_file

set :environment, ENV['RACK_ENV'].to_sym
set :root, root_dir
set :app_file, app_file
disable :run

run Sinatra::Application

set :app_file won't load them for you.



Related Topics



Leave a reply



Submit