我使用的是 VPS(ubuntu 12.04),上面有 php,python。 为了将 rails 项目部署到服务器上,我选择了 fcgi。
sudo aptitude install libapache2-mod-fcgid libfcgi-ruby1.9.1
a2enmod rewrite
vim /etc/apache2/sites-enabled/codepark.conf
<VirtualHost *:80>
   DefaultInitEnv RAILS_ENV development
   DocumentRoot /home/xxxxx/public
   ServerName www.codepark.us
   <Directory />
   AllowOverride All
   Options ExecCGI FollowSymLinks
   AllowOverride all
   Order allow,deny
   Allow from all
   </Directory>
</VirtualHost>
SetEnv RAILS_RELATIVE_URL_ROOT /xxxxx
RewriteEngine On
RewriteRule ^(.*)$ xxxxxx_cgi.fcgi [E=X-HTTP_AUTHORIZATION:%{HTTP:Authorization},QSA,L]
xxxxxx_cgi.fcgi
#!/usr/bin/ruby
require_relative '../config/environment'
class Rack::PathInfoRewriter
  def initialize(app)
    @app = app
  end
  def call(env)
    env.delete('SCRIPT_NAME')
    parts = env['REQUEST_URI'].split('?')
    env['PATH_INFO'] = parts[0]
    env['QUERY_STRING'] = parts[1].to_s
    @app.call(env)
  end
end
Rack::Handler::FastCGI.run  Rack::PathInfoRewriter.new(Xxxxx::Application)