如何在 Apache 下使用Passenger 设置Sinatra 应用程序? [英] How do I set up a Sinatra app under Apache with Passenger?

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

问题描述

假设我有最简单的单文件 Sinatra 应用程序.他们主页上的 hello world 就可以了.我想在 Apache 下使用 Phusion Passenger(又名 mod_rails)运行它.

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 文件中放入什么?
  • 我知道我需要一个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>

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

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

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆