本文介绍了如何在带有乘客的Apache下设置Sinatra应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我有最简单的单文件Sinatra应用程序.他们首页上的 hello world 即可.我想用Phusion Passenger(又名mod_rails)在Ap​​ache下运行它.

Let's say I have the simplest single-file Sinatra app. The hello world on their homepage will do. I want to run it under Apache with Phusion Passenger, AKA mod_rails.

  • 我需要什么目录结构?
  • 我必须在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>

config.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为空.

  • Heroku rack documentation
  • Phusion Passenger documentation

这篇关于如何在带有乘客的Apache下设置Sinatra应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-16 22:05