Provision and deploy to an Ubuntu/God/Apache/Passenger stack using Capistrano and EC2.
- Create an Ubuntu Hardy EC2 instance in one command (
cap ec2
) - Provision a solid Ubuntu Hardy application server in one command (
cap ubuntu
) - Deploy PHP, Rails, and Sinatra apps
- Be descriptive about what is going on and allow the user to opt out
- Simplify the
deploy.rb
file
- Apache
- EC2 (optional)
- Git
- MySQL
- MySQLTuner
- Perl
- PHP
- Postfix (relay)
- Ruby
- RubyGems
- Passenger (mod_rails)
- God
- Rails
- Sinatra
- Sphinx
gem install winton-ubistrano
cd your_project ubify .
- Runs
capify
- Creates
config/deploy.example.rb
- Adds
config/deploy.rb
to your project's.gitignore
It should look like this:
set :ubistrano, { :application => :my_app, :platform => :rails, # :php, :rails, :sinatra :repository => 'git@github.com:user/my-app.git', :ec2 => { :access_key => '', :secret_key => '' }, :mysql => { :root_password => '', :app_password => '' # Ubistrano creates a mysql user for each app }, :production => { :domains => [ 'myapp.com', 'www.myapp.com' ], :ssl => [ 'myapp.com' ], :host => '127.0.0.1' }, :staging => { :domains => [ 'staging.myapp.com' ], :host => '127.0.0.1' } } require 'ubistrano'
Ubistrano uses the same Capistrano options you've come to love, but provides defaults and a few extra options as well.
Edit deploy.rb to the best of your ability. If setting up an EC2 instance, be sure to provide your AWS keys. Your IP address will be provided later. Provide passwords even if they haven't been created yet.
Feel free to move any options into or out of the stage groups.
cap ec2
================================================================================ Press enter for Ubuntu Hardy or enter an AMI image id:
cap ubuntu
================================================================================ Let's set up an Ubuntu server! (Tested with 8.04 LTS Hardy) With each task, Ubistrano will describe what it is doing, and wait for a yes/no. ================================================================================ Please ssh into your server (use -i only for EC2): ssh root@174.129.232.34 -i ~/.ssh/id_rsa-studicious Edit your sudoers file: visudo Add the following line: deploy ALL=NOPASSWD: ALL Continue? (y/n)
All apps should have a public
directory.
cap deploy:first
cap deploy
Use any capistrano task, but replace cap
with cap staging
.
cap staging deploy:first