Deploying Rack Apps on Dreamhost via Passenger (including Sinatra)
I don’t like deployment via FastCGI that much. It’s just too unstable, and random for my tastes. So when I saw that Passenger was going to support Rack, I knew I had to get that working on Dreamhost.
Once I started going at it, it only took me a few minutes to make everything work. You can find documentation at the Passenger Github repository.
Steps:
- Setup your account to support mod_rails
- Create the directory structure
- Make a rackup file (config.ru)
- Create a very simple Sinatra application
1) Setting up the account
- Domains -> Manage Domains -> Edit (web hosting column)
- Enable “Ruby on Rails Passenger (mod_rails)”
- Add the public directory to the web directory box. So if you were using “gittr.com”, it would change to “gittr.com/public”
- Save your changes
2) Creating the directory structure
domain.com/ domain.com/tmp domain.com/public # a vendored version of sinatra - not necessary if you use the gem domain.com/sinatra
3) Creating a rackup file
# This file goes in domain.com/config.ru require 'sinatra/lib/sinatra.rb' require 'rubygems' Sinatra::Application.default_options.merge!( :run => false, :env => :production ) require 'test.rb' run Sinatra.application
4) A very simple Sinatra application
# this is test.rb referred to above get '/' do "Worked on dreamhost" end get '/foo/:bar' do "You asked for foo/#{params[:bar]}" end
And that’s all there is to it! Once it’s all setup, point your browser at your domain, and you should see a “Worked on Dreamhost” page. To restart the application after making changes, you need to run “touch tmp/restart.txt”.
June 21st, 2008 at 5:35 am
where does the app logs?
is possibly to define a RackEnv development
on dreamhost? bye
June 24th, 2008 at 1:31 pm
Yes the app logs, is there some agreed upon standard/assumption. So far I haven’t found a single Sinatra example (including the deployment ones), mention about the log file.
June 24th, 2008 at 2:42 pm
It’s a good question. Sinatra uses Rack’s CommonLogger middleware to do request logging. But beyond that I have no idea how logs work in Sinatra. I’ll look it up, and write up a post on it.
June 24th, 2008 at 3:11 pm
[…] of this this blog I suspect would be the one which talks (in nice, easy-to-understand terms) about how to deploy Rack-based applications to Dreamhost using their new Passenger support. SHARETHIS.addEntry({ title: “Deploying Rack Applications to […]
July 4th, 2008 at 12:13 pm
[…] awesome!) and thought I’d deploy something to my mess-around DreamHost account. I followed these instructions which totally worked and was so easy. But when it came time to actually deploy my real app with […]