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 […]
October 9th, 2008 at 11:24 pm
[…] be able to deploy this new app to my Dreamhost account. A quick search turned up a useful post with information on deploying to Sinatra apps on Dreamhost. Unfortunately, the first attempt didn’t […]
November 10th, 2008 at 12:02 am
HI,
I’m trying to deploy a new rack framework and following all your steps: the config.ru is loaded after I fixed the requires but hitting my domain only display a totally empty page, it seems is showing the /public folder since I can see the /images folder but is not running the rack app, any ideas, is the public folder supposed to have a symlink or magic file? I have all the tmp/ folder also and I restarted the passenger but nothing, blank page again.
Thanks, Peter.
November 15th, 2008 at 8:22 am
worked fine, thanks!