Search code examples
apachesymfonycapistranorm

rm command is not execed by Permission denied


in my deploy script deploy.rb

lock "3.11.0"

set :application, "myapp"
set :repo_url, "ssh://app@git.whitebear.com/home/app/myGit/myapp.git"

set :branch, 'master'
set :deploy_to, "/var/www/html/myapp"

#set :linked_files, %w{app/config/parameters.yml}
set :linked_dirs, %w{log vendor var node_modules public/build public/dlstore config/spool}
#somehow app/cache doesn't work...

set :format, :pretty
set :log_level, :debug
set :keep_releases, 3

after 'deploy:starting', 'composer:install_executable'

set :yarn_flags, "--prefer-offline --production --no-progress"
set :yarn_roles, :app

in production.rb

set :stage, :prod
set :symfony_env, "prod"

set :webserver_user, "app"
#set :controllers_to_clear, ["app_*.php"]
set :composer_install_flags, '--prefer-dist --no-interaction --optimize-autoloader'

server 'myapp.com', user: 'app', port: 22, roles: %w{app db web} # edit IP / Port and SSH user of your production server
SSHKit.config.command_map[:composer] = "php #{shared_path.join("composer.phar")}"

I set keep_releases 3, however when I deployed I have permission problems.

I don't know why permission is changed by Aapache though,

Is it possible forcely exec rm when deploying??

 DEBUG [cd2bf6b1]   cannot remove `/var/www/html/myApp/releases/20190212120003/var/cache/prod/pools/VQruNbwKF0/X/3/tCcgRMw5TEmYO-kHpJ0t'
 DEBUG [cd2bf6b1]   : Permission denied

Solution

  • This is a common problem caused by poor server configuration or deployment ran via wrong user. You u try to execute a script with user x and permissions for that file belongs to www-data and your user x is unable to remove it you will get this error. Your user has to have rights to remove that file. The user which executes the script is not the same as user that executes web request.