簡體   English   中英

Rails 4.2.3應用程序不能在生產環境中工作,但可以在開發環境中工作

[英]Rails 4.2.3 app not working in production environment but working in development environment

我將Rails應用程序部署在AWS實例上,如果我將環境更改為開發而不是.conf文件中的生產環境,則可以正常工作。

以下是production.log內容的輸出

I, [2015-10-01T08:22:36.180713 #3376]  INFO -- : Started GET "/" for 123.252.135.162 at 2015-10-01 08:22:36 +0000
F, [2015-10-01T08:22:36.201807 #3376] FATAL -- : 
ActionController::RoutingError (No route matches [GET] "/"):

以下是production.rb文件的內容

# config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present?
config.serve_static_files = true

# Compress JavaScripts and CSS.
config.assets.js_compressor = :uglifier
# config.assets.css_compressor = :sass

# Do not fallback to assets pipeline if a precompiled asset is missed.
config.assets.compile = true

# Asset digests allow you to set far-future HTTP expiration dates on all assets,
# yet still be able to expire them through the digest params.
config.assets.digest = true

我嘗試跑步

RAILS_ENV=production bundle exec rake assets:precompile

在公共目錄中生成了資產文件夾。 但是,當我訪問應用程序的URL時,它仍然顯示您要查找的頁面不存在。

我想出了解決方案。 實際上,如果我訪問其他資源(例如,

myapp.com/users

但是,當我訪問myapp.com它顯示的頁面不存在。 這是因為rails default服務器在開發環境中提供了rails默認頁面,但是當我嘗試在生產環境中運行相同的頁面時,nginx卻不提供rails的默認頁面。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM