How can I get Capistrano to include .htaccess files in deployments?

I am trying to get Capistrano to deploy my web application. I am deploying a php application using remote_cache from a git repository to a Linux host through a Windows computer. Everything deploys well, except that it does not copy .htaccess files. I am new to Capistrano and Ruby, so any pointers would be helpful!

Capistrano 2.5.18 with Ruby 1.8.6 on Windows

+3
source share
3 answers

htaccess , /symlink

  desc "remove .htaccess"
  task :htaccess do
    run "rm #{path}/.htaccess"
    run "ln #{path}/.htaccess #{release_path}/public/.htaccess"
  end
+1

Here is what worked for me, but I'm on site5, so the contents of your htaccess file will probably be different; At the bottom of my deploy.rb file, I added the following:

after "deploy:create_symlink", "MYAPPNAME:htaccess_setup"


namespace :MYAPPNAME do
  task :htaccess_setup, :roles => :app do
    htaccess = "PATHTOMYPUBLICDIR/.htaccess"
    run "if [ ! -f #{htaccess} ]; then echo 'PassengerEnabled On' > #{htaccess}; echo 'PassengerAppRoot #{current_path}' >> #{htaccess}; echo '.htaccess created'; else echo '.htaccess already exists (untouched)'; fi"
  end
end
0
source

Source: https://habr.com/ru/post/1748464/


All Articles