benlog.org: Deploy your Rails app in a subdirectory with Apache and Mongrel
Se lenken øverst først, så kan du se her for litt mer snask.
Hvis du bruker capistrano med denne kan det være greit med følgende i deploy.rb:
desc <<-DESC
Spinner is run by the default cold_deploy task. Instead of using script/spinner, we're just gonna rely on Mongrel to keep itself up.
DESC
task :spinner, :roles => :app do
application_port = 8000 #get this from your friendly sysadmin
run "mongrel_rails start -e production --prefix=/mgmwebapps -p #{application_port} -d -c #{current_path} -P /tmp/mongrl.pid"
end
Vi må kunne restarte mongrel også:
desc "Restart the web server"
task :restart, :roles => :app do
begin
run "cd #{current_path} && mongrel_rails restart -P /tmp/mongrl.pid"
rescue RuntimeError => e
puts e
puts "Probably not a big deal, so I'll just keep trucking..."
end
end
…og denne hvis du vil håndtere en egen database.yml:
desc "Create database.yml in shared/config"
task :after_setup do
database_configuration = render :template => <<-EOF
login: &login
adapter: mysql
host: localhost
username:
password: development:
database:
<<: *login
test:
database:
<<: *login
production:
database:
<<: *login
EOF
run "mkdir -p #{deploy_to}/#{shared_dir}/config"
put database_configuration, "#{deploy_to}/#{shared_dir}/config/database.yml"
end