5Minute Deployment
After you’ve secured your server and optionally set up SSH keys for easy access to your server, you’re ready to deploy your application.
If you are still using Capistrano 1, see Deployment With Capistrano1
If this is not the first application, be sure to read Deploying Additional Applications
- 1) Install gems on your development system.
sudo gem install capistrano railsmachine
sudo gem install termios
The termios gem prevents passwords from being displayed in capistrano. It may not compile on Windows.
- 2) Create your Rails application
rails my_app
cd my_app
- 3) Update database.yml
production:
database: myapp_prod
adapter: mysql
host: localhost
username: myapp_user
password: myapp_user_pass
In config/database.yml set the database name, user name, and password for your production database.
The user will be created for you so use any name you like except deploy.
Set the host to localhost.
- 3) Capify and Railsmachinify
capify .
railsmachine --apply-to . --name myapp --domain mydomain.com
You can use your_account.railsmachina.com if you don’t have a domain yet. In that case, edit the file config/deploy.rb and uncomment the line set :apache_default_vhost, true
- 4) Create your Subversion repository
Note: If you already have a publicly accessible repository or are using a different version control system edit your deploy.rb, commit the changes and skip this step. You might need to read about Capistrano Over Https.
cap repos:setup
cd ..\myapp_machine
- 5) Set up Apache, mongrel cluster, and the database
cap servers:setup
You will be asked to supply the deploy user’s database password and then the deploy user’s system password, which were both set when you secured your server.
- 6) Deploy your application
cap deploy:cold
- 7)Test it!
If you didn’t see any errors during the deployment, pull up your site and see how it looks.
Run cap -T to see the full list of tasks. The one you will use most often are:
cap deploy #deploy your latest code
cap deploy:migrations #deploy the latest code and run database migrations
Be sure to check out Tips And Tricks to see what else you can do with the railsmachine gem.
