我寫了一個簡單的帶有兩個「路由」的Sinatra應用程序:「/ show」和「/ listshows」。當我在Webrick之上運行應用程序時,靜態和非靜態路由都可以很好地工作。下面是URL就是我使用:部署Sinatra應用程序後的路徑問題
今天,我部署了我簡單的應用程序在Apache的頂部和乘客2.我的Web服務器是我的私人網絡上,並且是命名爲Millhouse。我基本上要使用以下URL來訪問應用程序:
的probem的是,「slwa」串是不是我的任何URL的一部分。例如,當您嘗試訪問「http:// millhouse/slwa」時,應該自動重定向到「http:// millhouse/slwa/listshows」。雖然我的應用程序確實重定向,但它最終會將我發送到「http:// millhouse/listshows」。 「slwa」部分丟失。
我不想創建一個新的虛擬主機,所以我在我的Ubuntu服務器上重新使用了「root」虛擬主機。這是我的虛擬主機:
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog /var/log/apache2/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog /var/log/apache2/access.log combined
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
### Here's the only line that I added to the default
RackBaseURI /slwa
</VirtualHost>
我還創建了一個符號鏈接在/ var/WWW指向在公開目錄爲我的應用程序。最後,這裏是我的config.ru:
# This is straight from the Phusion Passnger Users Guide"
require 'rubygems'
require 'sinatra'
root_dir = File.dirname(__FILE__)
set :environment, ENV['RACK_ENV'].to_sym
set :root, root_dir
set :app_file, File.join(root_dir, 'slwa.rb')
disable :run
require 'slwa'
run Sinatra::Application
我缺少什麼部分?
在此先感謝您的幫助!
湯姆金銀絲
我結束了使用EMK - 西納特拉的URL換包裝,使我的網址的工作。我甚至在我的博客上寫過 - http://tompurl.com/2011/01/17/sinatra-lessons-learned/。無論如何感謝Udo! – 2011-03-17 20:04:15