Capistrano is an open source tool for running scripts on multiple servers. It’s primary use is for easily deploying applications. While it was built specifically for deploying Rails apps, it’s pretty simple to customize it to deploy other types of applications. capifony is a deployment recipes collection that works with both symfony and Symfony2 applications. Taken from


In order to install capifony you have to use RubyGems. RubyGems is a package manager for ruby programs.

gem install capifony

On OSX you might need to use sudo.

sudo gem install capifony

Configuring deploy.rb

Go to folder of your Symfony2 application

cd your/path/to/s2_app

Now we have to initialize capifony.

capifony .

Capifony initialized

This will create two files Capfile and deploy.rb. The Capfile is a capifony configuration file and deploy.rb is a file where you write your server information.

You can ignore Capfile but we have to modify the deploy.rb file. It can be found in app/config/deploy.rb. Now if you were to open that file its contents should look something like this.

Replace the contents of deploy.rb with the following code:

Replace __1__ with your application’s name. Example: myApp

Replace __2__ with your domain name. Example:

If you’re unsure what to write on __3__ just use ssh to connect to your server and afterwards pwd to see what’s your folder’s name.

Replace __4__ with your server’s username

Replace __5__ with your server’s password

Replace __6__ with your port number. This step is optional and you should fill it out only if you’re not using default ssh port. Also don’t forget to remove # to uncomment that part of code.

Replace __7__ with your git repository. Example

__8__ you write here your folder’s name you want to share. This part will be explained in more detail later.

For __9__ see __3__

Configuring server

Now after we successfully modified our deploy.rb file we have to prepare our server for capifony. Use ssh to log on to your server.

You should be /home/_some_name

Create folders called releases and shared.

mkdir releases mkdir shared

When application is deployed capifony will clone your git repository in releases folder. In deploy.rb file there was line set :keep_releases, 3 you can change that number to any amount you want.

After your git repository has been cloned it will get the latest release and symlink it on to current folder. Contents of your shared folder will be symlinked to your current folder.

This is excellent when you have let’s say user uploaded images. This will enable you to share your images across releases. So if you were to replace __8__ with something like web/images that would symlink your images folder in your current release web folder.

The shared folder structure should be something like this:

shared/app/config/parameters.yml shared/web/.htaccess shared/web/images


Exit your ssh connection and position yourself to your symfony2 application:

cd your/path/to/s2_app

And now let’s deploy our symfony2 application.

cap deploy

Give it few minutes to complete and now you have to do one more final step. ssh to your server and symlink current/web to your public_html. If you already have public_html folder you have to first remove it.

rm -rf public_html
ln -s current/web public_html

You will have to do this last part of configuration only the first time.

For future deploys you only need to write cap deploy

Additional features

Capifony has lots of additional features to list them all write: cap -vT

I personally find very useful cap deploy rollback option.

Let’s say you deploy your application but there’s some bug in code so while you’re fixing it you can just write cap deploy rollback to revert to the previous release.


I believe I’ve demonstrated through this short tutorial just how easy it is to deploy your symfony2 applications using capifony. Sure you might have some trouble configuring all this the first time but in the long run it will pay off.

Read more