phusion passenger很热,和apache结合易于部署。
安装
gem 安装.
gem install passenger
命令行配置Passenger需要的Apache
passenger-install-apache2-module
配置
主要配置,其中,添加Virtual Host和注明DocumentRoot
# Admin email, Server Name (domain name) and any aliases ServerName example.com ServerAlias www.example.com # Index file and Document Root (where the public files are located) DocumentRoot /path/to/app/public
修改应用程序根目录的config.ru如下:
require 'rubygems' require 'sinatra' Sinatra::Application.default_options.merge!( :run => false, :env => ENV['RACK_ENV'], :app_file => File.expand_path(File.dirname(__FILE__) + '/main.rb'), :public => File.expand_path(File.dirname(__FILE__) + '/public'), :views => File.expand_path(File.dirname(__FILE__) + '/views') ) require 'main' run Sinatra.application
重启Apache
如果应用代码修改,要重启服务,所以,最好是创建快捷方式。在tmp/restart.txt,运行如下:
$ touch /path/to/app/tmp/restart.txt
如果是使用Capistrano部署,那么需要如下配置,以便重启:
namespace :deploy do # Restart passenger on deploy desc "Restarting mod_rails with restart.txt" task :restart, :roles => :app, :except => { :no_release => true } do run "touch #{current_path}/tmp/restart.txt" end end
相关
Passenger用法示例和 Phusion Passenger官方论坛