Search code examples
amazon-ec2capistranosymfony

Deploying Symfony2 app to ec2 using Capifony


I'm attempting to deploy my symfony2 app to my ec2 instance. I have my deploy.rb file configured and I'm able to initialize the server directory using cap deploy:setup. However, when I run cap deploy I get this error: failed "sh -c 'cd /var/www/html/capifonytest/releases/20110920052019 && php app/console cache:warmup --env=prod'" on xxx.xx.xxx.xx. Here's my deploy.rb file:

set :application, "capifonytest"

default_run_options[:pty] = true
set :scm, :git

set :deploy_to, "/var/www/html/#{application}"

set :repository, "[email protected]:myname/myrepo.git"
set :branch, "master"
set :ssh_options, { :forward_agent => true }

set :user, "ec2-user"
set :domain, "xxx.xx.xxx.xx"
ssh_options[:keys] = [File.join(ENV["AWS_HOME"], "tsmith.pem")]

role :web,        domain                         # Your HTTP server, Apache/etc
role :app,        domain                         # This may be the same as your `Web` server
role :db,         domain, :primary => true       # This is where Rails migrations will run

set :use_sudo, true
set  :keep_releases,  3

Does anyone know of a good tutorial/resource for deploying a symfony2 app to a ec2 instance or using capifony/capistrano to do so? Also, any tips or tricks to get symfony2 working on an ec2 instance would be greatly appropriated. I'm running the amazon linux ami 64bit, which I believe is based on centos.


Here's a more detailed snippet of the output:

servers: ["107.20.247.96"]
[107.20.247.96] executing command
** [out :: 107.20.247.96] find: /var/www/html/capifonytest/releases/2011092118<br /> 2846/web/css': No such file or directory<br /> ** [out :: 107.20.247.96] find:/var/www/html/capifonytest/releases/2011092118
2846/web/images': No such file or directory
** [out :: 107.20.247.96] find: /var/www/html/capifonytest/releases/2011092118<br /> 2846/web/js': No such file or directory<br /> command finished in 358ms<br /> triggering after callbacks fordeploy:finalize_update'
* executing `symfony:cache:warmup'
* executing "cd /var/www/html/capifonytest/releases/20110921182846 && php app/
console cache:warmup --env=prod"
servers: ["107.20.247.96"]
[107.20.247.96] executing command
** [out :: 107.20.247.96] PHP Warning: require_once(/var/www/html/capifonytest
/releases/20110921182846/app/../vendor/symfony/src/Symfony/Component/Locale/Reso
urces/stubs/functions.php): failed to open stream: No such file or directory in
/var/www/html/capifonytest/releases/20110921182846/app/autoload.php on line 25
** [out :: 107.20.247.96] PHP Fatal error: require_once(): Failed opening requ
ired '/var/www/html/capifonytest/releases/20110921182846/app/../vendor/symfony/s
rc/Symfony/Component/Locale/Resources/stubs/functions.php' (include_path='.:/usr
/share/pear:/usr/share/php') in /var/www/html/capifonytest/releases/201109211828
46/app/autoload.php on line 25
command finished in 302ms
* [deploy:update_code] rolling back
* executing "rm -rf /var/www/html/capifonytest/releases/20110921182846; true"
servers: ["107.20.247.96"]
[107.20.247.96] executing command
command finished in 280ms
failed: "sh -c 'cd /var/www/html/capifonytest/releases/20110921182846 && php app
/console cache:warmup --env=prod'" on 107.20.247.96


Solution

  • A little late, but...

    If you recursively chown and chgrp your deploy directory (in your case /var/www/html/#{application}) with the deploy user, capifony should be able to clear the caches. In other words:

    sudo chown -R ec2-user /var/www/html/#{application}
    sudo chgrp -R ec2-user /var/www/html/#{application}