开发者

How to have one public/.htaccess per stage using capistrano-ext

开发者 https://www.devze.com 2023-02-06 22:12 出处:网络
I\'m using Capistrano multistage (capistrano-ext) to deploy to staging or 开发者_JAVA百科production.

I'm using Capistrano multistage (capistrano-ext) to deploy to staging or 开发者_JAVA百科production.

The problem is I'm using Passenger in my shared hosting and need to specify the PassengerAppRoot in the public/.htaccess file. Obviously this is different between stages.

How can I keep different "stage-versions" of this file?


I haven't used capistrano-ext, but I'm assuming somewhere in your Capfile you'll have the stage as a variable. Let's assume it's the variable 'stage'. Let's also assume you have the two different versions checked in somewhere in your code (public/.htaccess-{production|staging})

You could set up a task to symlink (or copy) the right file after a deploy:

desc 'Set up a stage-appropriate .htaccess file'
task 'update_htaccess' do
  run "ln -s #{release_path}/public/.htaccess-#{stage} #{release_path}/public/.htaccess"
end

after "deploy:update_code", "update_htaccess"
0

精彩评论

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