【问题标题】:Sinatra App 404 Error In Production Mode生产模式下的 Sinatra App 404 错误
【发布时间】:2011-10-16 21:14:56
【问题描述】:

我的制作设置如下:

  • Ubuntu 10.10
  • 导轨 3.1.1
  • 乘客 3.0.9
  • Sinatra 1.3.1
  • Apache 2.2.17

我已经在我的开发机器上测试了我的应用程序没有问题,但是当我部署到我的生产服务器时,我得到一个页面未找到错误显示(不是通常的 apache 错误)。

我可以毫无问题地使用 rackup config.ru 运行,因此假设它必须是 apache / 乘客问题,并且可能与路径有关。我现在已经厌倦了两台不同的服务器,都给出了同样的错误。

我的config.ru文件如下:

require 'rubygems'
require 'sinatra'

use Rack::ShowExceptions

#set :public_folder, File.expand_path(File.dirname(__FILE__) + "/public")
#set :views, File.expand_path(File.dirname(__FILE__) + "/views")

root_dir = File.dirname(__FILE__)
set :root,        root_dir
disable :run

FileUtils.mkdir_p 'log' unless File.exists?('log')
log = File.new("log/sinatra.log", "a")
$stdout.reopen(log)
$stderr.reopen(log)

#use Rack::ShowExceptions

require File.dirname(__FILE__) + "/bin/hsloginapp"
run Sinatra::Application

我的虚拟主机文件:

<VirtualHost *:4090>
    ServerName sinatra-demo.xxxxxxx.net
    DocumentRoot "/var/www/html/hsloginapp/production/current/public"
    <Directory /var/www/html/hsloginapp/public>
        Order allow,deny
        Allow from all
        Options FollowSymLinks
    </Directory>
</VirtualHost>

我的应用有点过于复杂,无法在此处粘贴所有内容,但如果需要,我很乐意粘贴部分内容。

我对一个简单的 sinatra 应用程序没有任何问题,因此感觉一切运行良好。现在已经花了四天时间 - 这让我很生气。

甚至看不出这个 404 是从哪里来的。我在 sinatra.log 中只能看到:

[16/Oct/2011 20:55:41] "GET / " 404 18 0.0008

我的公用文件夹中没有索引文件 - 尽管我的其他乘客/铁路应用程序中没有索引文件...

任何建议都非常感谢!

-- 更新--

考虑到我的 apache 配置可能已经被填满,我安装了 nginx 并获得了相同的 Not Found 页面。这在我的文件系统中似乎不存在。

查看我的 sinatra 日志,看起来 webrick 正在启动 - 我不知道为什么?

2011-10-22 15:13:12] INFO  WEBrick 1.3.1
[2011-10-22 15:13:12] INFO  ruby 1.8.7 (2010-08-16) [x86_64-linux]
[2011-10-22 15:13:17] WARN  TCPServer Error: Address already in use - bind(2)
== Someone is already performing on port 4990!
94.194.200.254 - - [22/Oct/2011 15:13:17] "GET / " 404 18 0.0636
94.194.200.254 - - [22/Oct/2011 15:13:18] "GET /favicon.ico " 404 18 0.0012

我想这就是问题所在?!需要帮助:)

-- 更新 2--

刚刚在我的 nginx 错误日志中注意到系统正在尝试加载 public/index.html

*9 "/var/www/html/hotspotlogin/public/index.html" is not found (2: No such file or directory)

passenger / nginx 不应该知道在这里做什么吗??!

【问题讨论】:

  • 要检查的一点:apache 用户是否对您的应用程序部署目录上方的所有目录具有读取和执行权限?
  • 嗨@matt - 只是从字面上尝试过。 chmod所有文件,包括apache root到777看看。仍然没有喜悦。感谢帮助:)
  • 我可以注意到您的 DocumentRoot 和 Directory 规则不同吗?或者它就在问题中
  • 嗨@matt。它们在我的生产服务器上是相同的,但我缩短了因为它们有公司域。不过很好发现;)
  • 您在哪里设置了乘客或代理?

标签: apache sinatra passenger


【解决方案1】:

问题可能是您没有正确设置乘客。

在 Apache 上,请确保您在某处有此行:

LoadModule passenger_module /somewhere/passenger-x.x.x/ext/apache2/mod_passenger.so

在 nginx 上,您的配置应包含以下行:

passenger_enabled on;

请注意,您正在尝试使用 WEBRick 运行 Sinatra,而不是在上面的日志示例中使用 Rassenger/Apache(并且该端口不可用)。要使用Passenger 运行它,您必须写一个config.ru,因为Passenger 对Sinatra 一无所知。

【讨论】:

  • 嗨。明天上午我会发布我的 config.ru。尽管日志说用于备份,但不要认为它试图与 webrick 一起运行。任何空白的 sinatra 应用程序都运行得很好 :( 另外,我在其他地方加载了乘客的东西,但可以在这个虚拟主机中尝试。Nginx 有它在服务器配置中。J
猜你喜欢
  • 2018-09-06
  • 2012-07-21
  • 1970-01-01
  • 2021-08-10
  • 1970-01-01
  • 2011-07-16
  • 1970-01-01
  • 2018-11-19
  • 1970-01-01
相关资源
最近更新 更多