deploying environment specific .htaccess files in Ruby on Rails
I have a .htaccess file with a line that specifies the environment for the application I am running (staging, production etc..)
RackEnv staging
Whats the best way to handle this for environment specific deployments wit开发者_StackOverflow中文版h capistrano and capistrano-ext?
somehow write to it dynamically in a capistrano task? symbolically link to an existing, shared .htaccess that is specific for each deployment, much in the same way as you do for database.yml?
are there any other options? thanks
Rather than put this in your .htaccess file you could add it to your apache config file for that app, typically this would be /etc/apache2/sites-available/yoursite
Here is an example of a file such as this with your setup ...
<VirtualHost *:80>
ServerName yoursite.com
ServerAlias yoursite.*
DocumentRoot /var/www/httpdocs/current/public
<Directory /var/www/httpdocs/current/>
Allow from all
Options -MultiViews
</Directory>
RackEnv staging
RailsEnv staging
# Logfiles
ErrorLog /var/www/logs/error.log
CustomLog /var/www/logs/access.log combined
</VirtualHost>
Then in your deploy.rb file separate out the site specific stuff, like this ...
task :staging do
set :application, "yoursite"
set :repository, "yoursite.git"
set :branch, "master"
set :deploy_to, "/var/www/httpdocs/currebt"
server "staging.yoursite.com", :app, :web, :db, :primary => true
set :rails_env, "staging"
end
If all that is setup you can then run
cap staging deploy
精彩评论