1

I'm using Capifony to deploy my Symfony2 application to my server and have been using it for a few months now. However, today when I deployed to my server I suddenly started getting permission denied errors! I've never had these before and I haven't changed any permissions no the server, in fact, I only deployed an hour or so before and it was fine?! Here is an example of the errors:

** [out :: xx.xxx.xxx.xxx] 
 ** [out :: xx.xxx.xxx.xxx] rm:
 ** [out :: xx.xxx.xxx.xxx] cannot remove `/var/www/vhosts/xyz.co.uk/releases/20130604203446/web/bundles/website/lib/frontend/img/blog/pop-2.jpg': Permission denied
 ** [out :: xx.xxx.xxx.xxx] 
 ** [out :: xx.xxx.xxx.xxx] rm:
 ** [out :: xx.xxx.xxx.xxx] cannot remove `/var/www/vhosts/xyz.co.uk/releases/20130604203446/web/bundles/website/lib/frontend/img/awaitingimages.jpg': Permission denied
 ** [out :: xx.xxx.xxx.xxx] 
 ** [out :: xx.xxx.xxx.xxx] rm:
 ** [out :: xx.xxx.xxx.xxx] cannot remove `/var/www/vhosts/xyz.co.uk/releases/20130604203446/web/bundles/website/lib/frontend/img/ratingsprite.gif': Permission denied
 ** [out :: xx.xxx.xxx.xxx] 
    command finished in 561ms
failed: "sh -c 'if [ `readlink /var/www/vhosts/xyz.co.uk/current` != /var/www/vhosts/xyz.co.uk/releases/20130604203446 ]; then rm -rf /var/www/vhosts/xyz.co.uk/releases/20130604203446; fi'" on xx.xxx.xxx.xxx

I get a load of these errors. I'm using the same deploy user as I always have. I'm wondering if it's anything to do with when composer updates. Here is my composer.json file:

{
    "name": "symfony/framework-standard-edition",
    "description": "The \"Symfony Standard Edition\" distribution",
    "autoload": {
        "psr-0": { "": "src/" }
    },
    "require": {
        "php": ">=5.3.3",
        "symfony/symfony": "2.2.*",
        "doctrine/orm": "~2.2,>=2.2.3",
        "doctrine/doctrine-bundle": "1.2.*",
        "twig/extensions": "1.0.*",
        "symfony/assetic-bundle": "2.1.*",
        "symfony/swiftmailer-bundle": "2.2.*",
        "symfony/monolog-bundle": "2.2.*",
        "sensio/distribution-bundle": "2.2.*",
        "sensio/framework-extra-bundle": "2.2.*",
        "sensio/generator-bundle": "2.2.*",
        "jms/security-extra-bundle": "1.4.*",
        "jms/di-extra-bundle": "1.3.*",
        "egeloen/ckeditor-bundle": "2.*",
        "knplabs/knp-menu-bundle": "1.1.*",
        "doctrine/doctrine-fixtures-bundle": "dev-master",
        "doctrine/data-fixtures": "dev-master",
        "egeloen/google-map-bundle": "*",
        "willdurand/geocoder": "*",
        "kriswallsmith/buzz": "*",
        "phpunit/phpunit": "3.7.*",
        "phpunit/php-invoker": "*",
        "doctrine/doctrine-migrations-bundle": "dev-master",
        "liuggio/rackspace-cloud-files-streamwrapper": ">=2.1",
        "liuggio/rackspace-cloud-files-bundle": ">=2.1",
        "avalanche123/imagine-bundle": "v2.1"
    },

    "scripts": {
        "post-install-cmd": [
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile"
        ],
        "post-update-cmd": [
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile"
        ]
    },

    "config": {
        "bin-dir": "bin",
        "bin-dir": "/usr/local/bin/"
    },
    "minimum-stability": "dev",

    "extra": {
        "symfony-app-dir": "app",
        "symfony-web-dir": "web",
        "symfony-assets-install": "symlink",
        "branch-alias": {
            "dev-master": "2.2-dev"
        }
    }
}

Here is my deploy.rb script:

set :stage_dir, 'app/config/deploy' # needed for Symfony2 only
set :stages, %w(production staging development)
require 'capistrano/ext/multistage'

set :application,           "xyz.co.uk"
set :user,                  "deployer"  # The server's user for deploys

set :normalize_asset_timestamps, false

set :repository,            "git@github.xyz/xyz.co.uk.git"
set :scm,                   :git
set :keep_releases,         5
after "deploy:update",      "deploy:cleanup"
set :use_sudo,              true
set :web_path,              "web"
set :shared_files,          ["app/config/parameters.yml", "web/.htaccess"]
set :shared_children,       [app_path + "/logs", web_path + "/uploads", "vendor"]
set :use_composer,          true
set :update_vendors,        true
set :dump_assetic_assets,   true
set :deploy_via,            :remote_cache

set :writable_dirs,       ["app/cache", "app/logs", "web/uploads"]
set :webserver_user,      "www-data"
set :permission_method,   :acl
set :use_set_permissions, true


logger.level = Logger::MAX_LEVEL

My production.rb script:

server 'xx.xxx.xxx.xxx', :app, :web, :primary => true
ssh_options[:port] = xxxx
ssh_options[:forward_agent] = true
default_run_options[:pty] = true

set :deploy_to, "/var/www/vhosts/xyz.co.uk/"

set :symfony_env_prod, "prod"
set :branch, "master"

after 'deploy:finalize_update', 'symfony:project:clear_controllers'
user1961082
  • 1,015
  • 17
  • 41

1 Answers1

0

My first guess here is that you should not use set :permission_method, :acl, but set it to chmod. Check this out - Automatically set proper permissions. Btw, which version of Unix do you run?

Also check that you really need to specify user and use_sudo at the same time. It can be the reason too.

Anton Babenko
  • 6,586
  • 2
  • 36
  • 44
  • Thanks ill try that. Any reason why it has only just started though? I thought it must have been to do with one of the dependencies when composer installs/updates?! – user1961082 Jun 04 '13 at 22:30
  • Do my composer.json file and scripts look correct for production apart from what you mentioned previously? I.e the symfony version etc. – user1961082 Jun 04 '13 at 22:34
  • I would keep `"bin-dir"` once, remove lines `"minimum-stability": "dev"` and `"branch-alias": { "dev-master": "2.2-dev" }`, but the rest looks good. Also compare versions to `symfony-standard` distribution [composer.json](https://github.com/symfony/symfony-standard/blob/v2.2.2/composer.json) and [composer.lock](https://github.com/symfony/symfony-standard/blob/v2.2.2/composer.lock) – Anton Babenko Jun 05 '13 at 07:02
  • SOrry how do you mean keep "bin-dir" once? Also, what's the reason for removing those? Should I replace them with anything? Thanks – user1961082 Jun 05 '13 at 10:16
  • I think the problem was with composer updating and then some dependencies being out of date such as assetic being 2.1 instead of 2.3 – user1961082 Jun 05 '13 at 15:49