【发布时间】:2010-10-08 03:35:23
【问题描述】:
我编写了一个简单的 Sinatra 应用程序,其中包含两个“路由”:“/show”和“/listshows”。当我在 Webrick 上运行应用程序时,静态和非静态路由的一切都运行良好。以下是我使用的 URL:
今天,我在 Apache 和 Passenger 2 之上部署了我的简单应用程序。我的 Web 服务器在我的专用网络上,名为 Millhouse。我基本上想使用以下 URL 访问应用程序:
问题是“slwa”字符串不是我的任何 URL 的一部分。例如,当您尝试访问“http://millhouse/slwa”时,您应该被自动重定向到“http://millhouse/slwa/listshows”。虽然我的应用程序确实重定向,但它最终将我发送到“http://millhouse/listshows”。缺少“slwa”部分。
我不想创建一个新的虚拟主机,所以我在我的 Ubuntu 服务器上重用了“根”虚拟主机。这是我的虚拟主机:
<VirtualHost *:80>
ServerAdmin webmaster@localhost
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
我错过了哪一部分?
提前感谢您的帮助!
汤姆·普尔
【问题讨论】: