Reputation: 1035
When deploying my dev environment to my external dev server using capistrano I always get the following error:
RuntimeException: Failed to write cache file "/var/www/xyz.co.uk/app/cache/dev/classes.php".
Then I have to log into my development server and delete my app/cache/dev/ directory.
Here is my development.rb file:
server 'x.xx.xx.xxx', :app, :web, :db, :primary => true
ssh_options[:port] = 1234
ssh_options[:forward_agent] = true
set :deploy_to, "/var/www/xyz.co.uk"
set :symfony_env_prod, "dev"
set :branch, "develop"
# Need to clear *_dev controllers
set :clear_controllers, false
And my deploy.rb file:
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, "root" # The server's user for deploys
set :normalize_asset_timestamps, false
set :repository, "[email protected]:xyz/xyz.co.uk.git"
set :scm, :git
set :keep_releases, 3
set :use_sudo, false
set :web_path, "web"
set :shared_files, ["app/config/parameters.yml"]
set :shared_children, [app_path + "/logs", web_path + "/uploads"]
set :use_composer, true
set :update_vendors, true
set :dump_assetic_assets, true
set :deploy_via, :remote_cache
#logger.level = Logger::MAX_LEVEL
Upvotes: 3
Views: 1303
Reputation: 901
Add this code
set :writable_dirs, ["app/cache", "app/logs"]
set :webserver_user, "www-data"
set :permission_method, :acl
set :use_set_permissions, true
Make sure that you have acl enabled. If not, refer to this link http://vvv.tobiassjosten.net/symfony/symfony2-file-permissions-in-ubuntu/
Upvotes: 0
Reputation: 44841
I have this in my deploy.rb
file to set the permissions on the cache directory:
after "deploy:update_code" do
capifony_pretty_print "--> Ensuring cache directory permissions"
run "setfacl -R -m u:www-data:rwX -m u:`whoami`:rwX #{latest_release}/#{cache_path}"
run "setfacl -dR -m u:www-data:rwX -m u:`whoami`:rwX #{latest_release}/#{cache_path}"
capifony_puts_ok
end
Upvotes: 4
Reputation: 6644
You are deploying as root
, so you have to use sudo
:
set :use_sudo, true
Upvotes: 0