How do I set up a Sinatra app under Apache with Passenger?

后端 未结 2 747
余生分开走
余生分开走 2020-12-22 20:17

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.

2条回答
  •  [愿得一人]
    2020-12-22 21:05

    Basic directory structure:

    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
    

    Virtual host file:

    
      ServerName    app.example.com
      DocumentRoot  /path/to/app/public
      
        Order       allow,deny
        Allow       from all
      
    
    

    config.ru

    # encoding: UTF-8
    require './hello-app'
    run Sinatra::Application
    

    hello-app.rb (sample application):

    #!/usr/bin/env ruby
    # encoding: UTF-8
    require 'rubygems' # for ruby 1.8
    require 'sinatra'
    
    get '/hi' do
      "Hello World!"
    end
    

    restart.txt is empty.


    Mildly useful links:

    • Heroku rack documentation
    • Phusion Passenger documentation

提交回复
热议问题