Capistrano is an open source tool for running scripts on multiple servers; its main use is deploying web applications. It automates the process of making a new version of an application available on one or more web servers, including supporting tasks such as changing databases.
Run or adapt the following depending the OS you are using.
On your Mac operating system
gem install capistrano
On your Linux machine with apt
apt-get update && aptget install capistrano
Finger in the nose! 😀
Configuring Capistrano to deploy your application
Create your application folder
Now you need to “Capify” your application
This will create two files:
All the config is going to be in deploy.rb
Givin name to the application
set :application, "MyApp"
Setting the repository address
set :repository, "git@https://github.com/terraltech/MyApp.git"
What SCM you are using, in this case we are using git
set :scm, :git
Deploying destination path
set :deploy_to, "/var/www"
Setting authentication credentials for your SCM
set :scm_username, "git-user"
set :scm_password, "git-password"
we need to tell Capistrano where our servers are and what roles they each play
role :app, "terraltech.com"
role :web, "terraltech.com"
role :db, "terraltech.com", :primary => true
The addresses you place in each role are the addresses that Capistrano will SSH to, in order to execute the commands you give.
If needed you can tell Capistrano which user to use when trying to connect to the server
set :user, "admin"
role :app, "email@example.com"
Preview of my deploy.rb example
set :application, "my first application"
set :repository, "git://github.com/terraltech/MyApp.git"
set :scm, :git
set :deploy_to, "/Path/to/my/App/"
server "firstname.lastname@example.org", :app, :web, :db, :primary => true
This will log into your server and do a series of “mkdir” calls.
I added this line to my deploy.rb file because I don’t need to use sudo for creating folders
set :use_sudo, false
Pushing the Code, Kicking the Tires