2011-10-16 19 views
1

我的製作安裝的如下:西納特拉應用的404在生產模式

  • 的Ubuntu 10.10
  • 軌3.1.1
  • 客運3.0.9
  • 西納特拉1.3.1
  • 的Apache 2.2 .17

我已經在我的開發機器上測試了我的應用程序,沒有問題,但是當我部署到m y生產服務器,我得到一個頁面未找到錯誤顯示(不是通常的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 

我沒有在我的公用文件夾的索引文件 - 雖然我沒有一個在我的其他乘客/ Rails應用...

任何建議非常感謝!

- 更新 -

思考我的Apache配置可能已被塞滿,我安裝了nginx的,並得到相同的頁面未找到。這似乎並不存在於我的文件系統中的任何地方。

翻閱我的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 

我想這就是問題所在?幫助需要:)

- UPDATE 2 -

只注意到我的nginx的錯誤日誌,系統的嘗試加載公共/ index.html的

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

不宜乘客/ nginx的認識在這裏做什麼??!

+0

有一點需要檢查:apache用戶是否已經讀取並執行了應用程序部署目錄之上的所有目錄的權限? – matt

+0

嗨@matt - 只是字面上嘗試過。 chmod所有的文件,包括apache root到777看。還沒有快樂。感謝幫助:) –

+1

我可以注意到您的DocumentRoot和Directory規則有所不同嗎?或者它在 – Slartibartfast

回答

0

問題可能是您沒有正確設置乘客。

在Apache上,請確保您有這行的地方:

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

在nginx的,你的配置應該包括這樣一行:

passenger_enabled on; 

請注意,您正在嘗試與使用WEBrick運行西納特拉,不在日誌示例中的Rassenger/Apache上(並且該端口不可用)。爲了與Passenger一起運行,你必須寫一個config.ru,因爲乘客不知道關於Sinatra的事情。

+0

嗨。我明天會發布我的config.ru。不要以爲它試圖與webrick一起運行,雖然日誌說用於備份。任何空白的sinatra應用程序運行得很好:(另外,我有乘客的東西加載到其他地方,但可以嘗試在這個虛擬主機。Nginx的它在服務器conf。J –