Dreamhost is a great hosting, and now that they use Phusion Passenger (mod_rails), we can host Rack based applications, like Sinatra.
Adding the great repository hosting by github, we can have a professional deploying system for our home made projects.
- Create the folder structure:
myapp/ public/ tmp/ views/
- Create your sinatra app, myapp/mywebapp.rb
- Create the Passenger rackup file, myapp/config.ru
- In panel.dreamhost.com go to Manage Domains -> Add Domain/Sub Domain.
- Fill the domain/subdomain to host the application, enable mod_rails (Passenger), and add /public to the web directory.
- Install sinatra:
Connect to your host via SSH
gem install sinatra
This will install sinatra for your user in ~/.gem
Now we could upload via FTP the application to the new domain generated.
If we need to restart the app, just create a restart.txt file in the tmp folder
touch tmp/restart.txt
But we want to use git as repository of the code, and capistrano for the deployment instead of upload manually. This are the steps:
- Go to github.com and create the new repository.
- Go to your project folder initialize git, commit and push to our new repository:
cd myapp
git init
git add .
git commit -m'first import'
git remote add origin [email protected]:user/project.git
git push origin master - Configure capistrano;
cd myapp
mkdir config
capify .Edit config/deploy.rb
- Be sure that you have empty the domain folder in the server, and setup the capistrano structure:
cap deploy:setup - In Dreamhost edit your domain and add /current/public to the web directory.
- Now you can deploy:
cap deploy - After this steps, Passenger couldn’t find the sinatra gem again, but was solved installing it again. Weird…
Now you can also restart the app with:
cap deploy:restart












