假设我有最简单的单文件 Sinatra 应用程序。他们主页上的hello world就可以了。我想用 Phusion Passenger,AKA mod_rails 在 Apache 下运行它。
- 我需要什么目录结构?
- 我必须在 vhost conf 文件中放入什么?
- 我知道我需要一个机架文件。里面有什么,为什么?
app
|-- config.ru # <- rackup file
|-- hello-app.rb # <- your application
|-- public/ # <- static public files (passenger needs this)
`-- tmp/
`-- restart.txt # <- touch this file to restart app
<VirtualHost *:80>
ServerName app.example.com
DocumentRoot /path/to/app/public
<Directory /path/to/app/public>
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
# encoding: UTF-8
require './hello-app'
run Sinatra::Application
#!/usr/bin/env ruby
# encoding: UTF-8
require 'rubygems' # for ruby 1.8
require 'sinatra'
get '/hi' do
"Hello World!"
end
restart.txt
是空的。
带有乘客的机架应用程序的示例 vhost 文件:
<VirtualHost *:80>
ServerName server.local
ServerAlias *.server.local
DocumentRoot /dir/public
RackEnv development
<Directory /dir/public>
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
示例 Config.ru:
require File.expand_path('../boot.rb', __FILE__)
use Rack::Middleware
run Rack::Cascade.new([array])