开发者

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

开发者 https://www.devze.com 2023-01-02 00:18 出处:网络
I\'m trying to get Capistrano deploying my web app.I\'m deploying a php app using remote_cache from a git repo to a Linux host via a Windows computer.Everything is deploying okay except that it doesn\

I'm trying to get Capistrano deploying my web app. I'm deploying a php app using remote_cache from a git repo to a Linux host via a Windows computer. Everything is deploying okay except that it doesn't copy over the .htaccess files. I'm new to Capistrano and Ruby, so any pointers would be helpful!

Capistr开发者_C百科ano 2.5.18 with Ruby 1.8.6 on Windows


remove htaccess first manually, then remove/symlink every time you deploy

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


John, please see http://groups.google.com/group/capistrano/browse_thread/thread/c3f43079a8e221b3/a714ca05bc5eb1d1


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

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

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号