Konrad Podgórski Web Developer / Software Architect

Place where I used to write about code related things. Currently umaintained.

Capifony fix for deployment on servers with strict permission settings

Please keep in mind that this post was written more than 2 years ago and might be outdated.

Some servers (for instance VPS I use) doesn’t allow to run script if it’s group writeable.

Solution is to run chmod 644 on files and chmod 755 on directories inside current release. You could use this one liner: Setting permissions for files and directories

BUT it’s really pain in ass to do every deploy, not to mention few more seconds of downtime. To fix this add to your deploy.rb following lines

    # Fix persmissions on VPS
    after "deploy:update_code" do
      capifony_pretty_print "--> Fixing permissions"
      run "cd #{latest_release} && find . -type f -exec chmod 644 {} \\;"
      run "cd #{latest_release} && find . -type d -exec chmod 755 {} \\;"
      capifony_puts_ok
    end

This is sample deploy.rb file with above fix, don’t use it without thinking :-)

    # deploy.rb

    set   :application,   "My App"
    set   :deploy_to,     "/var/www/my-app.com"
    set   :domain,        "my-app.com"

    set   :scm,           :git
    set   :repository,    "ssh-gitrepo-domain.com:/path/to/repo.git"

    role  :web,           domain
    role  :app,           domain
    role  :db,            domain, :primary => true

    set   :use_sudo,      false
    set   :keep_releases, 3

    # Fix persmissions on VPS
    after "deploy:update_code" do
      capifony_pretty_print "--> Fixing permissions"
      run "cd #{latest_release} && find . -type f -exec chmod 644 {} \\;"
      run "cd #{latest_release} && find . -type d -exec chmod 755 {} \\;"
      capifony_puts_ok
    end

on

Find this post helpful? Spread the word, thanks.

Comments