假设我有最简单的单文件 Sinatra 应用程序。 hello world在他们的主页上就可以了。我想在 Apache 下使用 Phusion Passenger,又名 mod_rails 运行它。
- 我需要什么样的目录结构?
- 我必须在 vhost conf 文件中放入什么?
- 我知道我需要一个 rackup 文件。里面有什么,为什么?
最佳答案
基本目录结构:
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>
配置.ru
# encoding: UTF-8
require './hello-app'
run Sinatra::Application
hello-app.rb(示例应用程序):
#!/usr/bin/env ruby
# encoding: UTF-8
require 'rubygems' # for ruby 1.8
require 'sinatra'
get '/hi' do
"Hello World!"
end
restart.txt
为空。
稍微有用的链接:
关于ruby - 如何使用 Passenger 在 Apache 下设置 Sinatra 应用程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3371208/