我已经搜索了问题的解决方案,但我似乎无法找到我正在寻找的确切内容。
目前,我正在关注亚马逊提供的教程
如果我部署他们的示例应用程序并获得欢迎屏幕,那么一切正常。
但是,当我想部署我自己的应用程序时,按照上面提到的教程并使用rails生成一个脚手架项目,我得到“502 Bad Gateway”。
我按照this教程设置了一个任意的“博客”,它们演示了数据库交互等基础知识。
我成功了:
检查我的环境:
选项26使用eb init工具:Ruby 2.0.0(乘客独立)
选项“是”用于创建RDS数据库MySql
访问我的实例并转到/ high_scores时出现此错误消息:
502 Bad Gateway
的nginx / 1.4.5
I,[2014-06-18T19:07:45.310588#4524]信息 - :迁移到CreateHighScores(20140618173833) [EC2-用户@ IP-172-31 -
- 这是文件中唯一的东西
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.1.1'
gem 'multi_json', '1.7.8'
gem 'json'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.3'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails', '~> 4.0.0'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring', group: :development
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# Use unicorn as the app server
# gem 'unicorn'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
# Use debugger
# gem 'debugger', group: [:development, :test]
-------------------------------------
/var/app/support/logs/passenger.log
-------------------------------------
/usr/local/share/ruby/gems/2.0/gems/railties-4.1.1/lib/rails/initializable.rb:55:in `block in run_initializers'
/usr/share/ruby/2.0/tsort.rb:150:in `block in tsort_each'
/usr/share/ruby/2.0/tsort.rb:183:in `block (2 levels) in each_strongly_connected_component'
/usr/share/ruby/2.0/tsort.rb:219:in `each_strongly_connected_component_from'
/usr/share/ruby/2.0/tsort.rb:182:in `block in each_strongly_connected_component'
/usr/share/ruby/2.0/tsort.rb:180:in `each'
/usr/share/ruby/2.0/tsort.rb:180:in `each_strongly_connected_component'
/usr/share/ruby/2.0/tsort.rb:148:in `tsort_each'
/usr/local/share/ruby/gems/2.0/gems/railties-4.1.1/lib/rails/initializable.rb:54:in `run_initializers'
/usr/local/share/ruby/gems/2.0/gems/railties-4.1.1/lib/rails/application.rb:288:in `initialize!'
/var/app/current/config/environment.rb:5:in `<top (required)>'
config.ru:3:in `require'
config.ru:3:in `block in <main>'
/usr/local/share/ruby/gems/2.0/gems/rack-1.5.2/lib/rack/builder.rb:55:in `instance_eval'
/usr/local/share/ruby/gems/2.0/gems/rack-1.5.2/lib/rack/builder.rb:55:in `initialize'
config.ru:1:in `new'
config.ru:1:in `<main>'
/usr/local/share/ruby/gems/2.0/gems/passenger-4.0.41/helper-scripts/rack-preloader.rb:112:in `eval'
/usr/local/share/ruby/gems/2.0/gems/passenger-4.0.41/helper-scripts/rack-preloader.rb:112:in `preload_app'
/usr/local/share/ruby/gems/2.0/gems/passenger-4.0.41/helper-scripts/rack-preloader.rb:158:in `<module:App>'
/usr/local/share/ruby/gems/2.0/gems/passenger-4.0.41/helper-scripts/rack-preloader.rb:29:in `<module:PhusionPassenger>'
/usr/local/share/ruby/gems/2.0/gems/passenger-4.0.41/helper-scripts/rack-preloader.rb:28:in `<main>'
App 31927 stdout:
App 31927 stdout:
[ 2014-06-18 20:38:57.0761 31847/7f322494e700 Pool2/Implementation.cpp:883 ]: Could not spawn process for group /var/app/current#default: An error occured while starting up the preloader.
in 'void Passenger::ApplicationPool2::SmartSpawner::handleErrorResponse(Passenger::ApplicationPool2::SmartSpawner::StartupDetails&)' (SmartSpawner.h:455)
in 'std::string Passenger::ApplicationPool2::SmartSpawner::negotiatePreloaderStartup(Passenger::ApplicationPool2::SmartSpawner::StartupDetails&)' (SmartSpawner.h:566)
in 'void Passenger::ApplicationPool2::SmartSpawner::startPreloader()' (SmartSpawner.h:206)
in 'virtual Passenger::ApplicationPool2::ProcessPtr Passenger::ApplicationPool2::SmartSpawner::spawn(const Passenger::ApplicationPool2::Options&)' (SmartSpawner.h:752)
in 'void Passenger::ApplicationPool2::Group::spawnThreadRealMain(const Passenger::ApplicationPool2::SpawnerPtr&, const Passenger::ApplicationPool2::Options&, unsigned int)' (Implementation.cpp:804)
[ 2014-06-18 20:38:57.0764 31847/7f3222643700 agents/HelperAgent/RequestHandler.h:2210 ]: [Client 20] Cannot checkout session.
Error page:
database configuration does not specify adapter (ActiveRecord::AdapterNotSpecified)
/usr/local/share/ruby/gems/2.0/gems/activerecord-4.1.1/lib/active_record/connection_adapters/connection_specification.rb:184:in `spec'
/usr/local/share/ruby/gems/2.0/gems/activerecord-4.1.1/lib/active_record/connection_handling.rb:50:in `establish_connection'
/usr/local/share/ruby/gems/2.0/gems/activerecord-4.1.1/lib/active_record/railtie.rb:129:in `block (2 levels) in <class:Railtie>'
/usr/local/share/ruby/gems/2.0/gems/activesupport-4.1.1/lib/active_support/lazy_load_hooks.rb:38:in `instance_eval'
/usr/local/share/ruby/gems/2.0/gems/activesupport-4.1.1/lib/active_support/lazy_load_hooks.rb:38:in `execute_hook'
/usr/local/share/ruby/gems/2.0/gems/activesupport-4.1.1/lib/active_support/lazy_load_hooks.rb:45:in `block in run_load_hooks'
/usr/local/share/ruby/gems/2.0/gems/activesupport-4.1.1/lib/active_support/lazy_load_hooks.rb:44:in `each'
/usr/local/share/ruby/gems/2.0/gems/activesupport-4.1.1/lib/active_support/lazy_load_hooks.rb:44:in `run_load_hooks'
/usr/local/share/ruby/gems/2.0/gems/activerecord-4.1.1/lib/active_record/base.rb:326:in `<module:ActiveRecord>'
/usr/local/share/ruby/gems/2.0/gems/activerecord-4.1.1/lib/active_record/base.rb:23:in `<top (required)>'
/usr/local/share/ruby/gems/2.0/gems/activerecord-4.1.1/lib/active_record/relation/predicate_builder.rb:111:in `<class:PredicateBuilder>'
/usr/local/share/ruby/gems/2.0/gems/activerecord-4.1.1/lib/active_record/relation/predicate_builder.rb:2:in `<module:ActiveRecord>'
/usr/local/share/ruby/gems/2.0/gems/activerecord-4.1.1/lib/active_record/relation/predicate_builder.rb:1:in `<top (required)>'
/usr/local/share/ruby/gems/2.0/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:247:in `require'
/usr/local/share/ruby/gems/2.0/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:247:in `block in require'
/usr/local/share/ruby/gems/2.0/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:232:in `load_dependency'
/usr/local/share/ruby/gems/2.0/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:247:in `require'
/usr/local/share/ruby/gems/2.0/gems/activesupport-4.1.1/lib/active_support/dependencies/autoload.rb:70:in `block in eager_load!'
/usr/local/share/ruby/gems/2.0/gems/activesupport-4.1.1/lib/active_support/dependencies/autoload.rb:70:in `each'
/usr/local/share/ruby/gems/2.0/gems/activesupport-4.1.1/lib/active_support/dependencies/autoload.rb:70:in `eager_load!'
/usr/local/share/ruby/gems/2.0/gems/activerecord-4.1.1/lib/active_record.rb:155:in `eager_load!'
/usr/local/share/ruby/gems/2.0/gems/railties-4.1.1/lib/rails/application/finisher.rb:58:in `each'
/usr/local/share/ruby/gems/2.0/gems/railties-4.1.1/lib/rails/application/finisher.rb:58:in `block in <module:Finisher>'
/usr/local/share/ruby/gems/2.0/gems/railties-4.1.1/lib/rails/initializable.rb:30:in `instance_exec'
/usr/local/share/ruby/gems/2.0/gems/railties-4.1.1/lib/rails/initializable.rb:30:in `run'
/usr/local/share/ruby/gems/2.0/gems/railties-4.1.1/lib/rails/initializable.rb:55:in `block in run_initializers'
/usr/share/ruby/2.0/tsort.rb:150:in `block in tsort_each'
/usr/share/ruby/2.0/tsort.rb:183:in `block (2 levels) in each_strongly_connected_component'
/usr/share/ruby/2.0/tsort.rb:219:in `each_strongly_connected_component_from'
/usr/share/ruby/2.0/tsort.rb:182:in `block in each_strongly_connected_component'
/usr/share/ruby/2.0/tsort.rb:180:in `each'
/usr/share/ruby/2.0/tsort.rb:180:in `each_strongly_connected_component'
/usr/share/ruby/2.0/tsort.rb:148:in `tsort_each'
/usr/local/share/ruby/gems/2.0/gems/railties-4.1.1/lib/rails/initializable.rb:54:in `run_initializers'
/usr/local/share/ruby/gems/2.0/gems/railties-4.1.1/lib/rails/application.rb:288:in `initialize!'
/var/app/current/config/environment.rb:5:in `<top (required)>'
config.ru:3:in `require'
config.ru:3:in `block in <main>'
/usr/local/share/ruby/gems/2.0/gems/rack-1.5.2/lib/rack/builder.rb:55:in `instance_eval'
/usr/local/share/ruby/gems/2.0/gems/rack-1.5.2/lib/rack/builder.rb:55:in `initialize'
config.ru:1:in `new'
config.ru:1:in `<main>'
/usr/local/share/ruby/gems/2.0/gems/passenger-4.0.41/helper-scripts/rack-preloader.rb:112:in `eval'
/usr/local/share/ruby/gems/2.0/gems/passenger-4.0.41/helper-scripts/rack-preloader.rb:112:in `preload_app'
/usr/local/share/ruby/gems/2.0/gems/passenger-4.0.41/helper-scripts/rack-preloader.rb:158:in `<module:App>'
/usr/local/share/ruby/gems/2.0/gems/passenger-4.0.41/helper-scripts/rack-preloader.rb:29:in `<module:PhusionPassenger>'
/usr/local/share/ruby/gems/2.0/gems/passenger-4.0.41/helper-scripts/rack-preloader.rb:28:in `<main>'
/var/log/directory-hooks-executor.log
-------------------------------------
Resolving dependencies...
Using rake 10.3.2
Using i18n 0.6.9
Using json 1.8.1
Using minitest 5.3.5
Using thread_safe 0.3.4
Using tzinfo 1.2.1
Using activesupport 4.1.1
Using builder 3.2.2
Using erubis 2.7.0
Using actionview 4.1.1
Using rack 1.5.2
Using rack-test 0.6.2
Using actionpack 4.1.1
Using mime-types 1.25.1
Using polyglot 0.3.5
Using treetop 1.4.15
Using mail 2.5.4
Using actionmailer 4.1.1
Using activemodel 4.1.1
Using arel 5.0.1.20140414130214
Using activerecord 4.1.1
Using bundler 1.6.2
Using coffee-script-source 1.7.0
Using execjs 2.2.0
Using coffee-script 2.2.0
Using thor 0.19.1
Using railties 4.1.1
Using coffee-rails 4.0.1
Using hike 1.2.3
Using multi_json 1.7.8
Using jbuilder 2.1.1
Using jquery-rails 3.1.0
Using mysql2 0.3.16
Using tilt 1.4.1
Using sprockets 2.11.0
Using sprockets-rails 2.1.3
Using rails 4.1.1
Using rdoc 4.1.1
Using sass 3.2.19
Using sass-rails 4.0.3
Using sdoc 0.4.0
Using turbolinks 2.2.2
Using uglifier 2.5.1
Your bundle is complete!
Gems in the groups test and development were not installed.
Use `bundle show [gemname]` to see where a bundled gem is installed.
+ '[' 0 '!=' 0 ']'
+ echo 'bundle install succeeded'
bundle install succeeded
+ '[' -f Gemfile.lock ']'
+ echo 'encountered a Gemfile.lock, setting proper permissions'
encountered a Gemfile.lock, setting proper permissions
+ chown webapp:webapp Gemfile.lock
+ '[' '' = 1 ']'
+ true
2014-06-18 20:41:08,496 [INFO] (32051 MainThread) [directoryHooksExecutor.py-29] [root directoryHooksExecutor info] Script succeeded.
2014-06-18 20:41:08,496 [INFO] (32051 MainThread) [directoryHooksExecutor.py-29] [root directoryHooksExecutor info] Executing script: /opt/elasticbeanstalk/hooks/appdeploy/pre/11_asset_compilation.sh
2014-06-18 20:41:15,728 [INFO] (32051 MainThread) [directoryHooksExecutor.py-29] [root directoryHooksExecutor info] Output from script: running 'rake assets:precompile'...
I, [2014-06-18T20:41:15.568942 #32080] INFO -- : Writing /var/app/ondeck/public/assets/application-10faafa06109fa14582542ac1852f5c5.js
I, [2014-06-18T20:41:15.633955 #32080] INFO -- : Writing /var/app/ondeck/public/assets/application-cf0b4d12cded06d61176668723302161.css
Asset compilation succesful
2014-06-18 20:41:15,729 [INFO] (32051 MainThread) [directoryHooksExecutor.py-29] [root directoryHooksExecutor info] Script succeeded.
2014-06-18 20:41:15,729 [INFO] (32051 MainThread) [directoryHooksExecutor.py-29] [root directoryHooksExecutor info] Executing script: /opt/elasticbeanstalk/hooks/appdeploy/pre/12_db_migration.sh
2014-06-18 20:41:18,817 [INFO] (32051 MainThread) [directoryHooksExecutor.py-29] [root directoryHooksExecutor info] Output from script: == 20140618173833 CreateHighScores: migrating =================================
-- create_table(:high_scores)
-> 0.1183s
== 20140618173833 CreateHighScores: migrated (0.1184s) ========================
2014-06-18 20:41:18,817 [INFO] (32051 MainThread) [directoryHooksExecutor.py-29] [root directoryHooksExecutor info] Script succeeded.
2014-06-18 20:41:18,954 [INFO] (32096 MainThread) [directoryHooksExecutor.py-29] [root directoryHooksExecutor info] Executing directory: /opt/elasticbeanstalk/hooks/appdeploy/enact/
2014-06-18 20:41:18,955 [INFO] (32096 MainThread) [directoryHooksExecutor.py-29] [root directoryHooksExecutor info] Executing script: /opt/elasticbeanstalk/hooks/appdeploy/enact/01_flip.sh
2014-06-18 20:41:19,006 [INFO] (32096 MainThread) [directoryHooksExecutor.py-29] [root directoryHooksExecutor info] Output from script: + '[' -d /var/app/current ']'
+ rm -rf /var/app/current.old
+ mv /var/app/current /var/app/current.old
+ mv /var/app/ondeck /var/app/current
+ su -c 'mkdir -p /var/app/current/{tmp,public}' webapp
+ rm -rf /var/app/current.old
2014-06-18 20:41:19,006 [INFO] (32096 MainThread) [directoryHooksExecutor.py-29] [root directoryHooksExecutor info] Script succeeded.
2014-06-18 20:41:19,007 [INFO] (32096 MainThread) [directoryHooksExecutor.py-29] [root directoryHooksExecutor info] Executing script: /opt/elasticbeanstalk/hooks/appdeploy/enact/09clean.sh
2014-06-18 20:41:19,021 [INFO] (32096 MainThread) [directoryHooksExecutor.py-29] [root directoryHooksExecutor info] Output from script:
2014-06-18 20:41:19,021 [INFO] (32096 MainThread) [directoryHooksExecutor.py-29] [root directoryHooksExecutor info] Script succeeded.
2014-06-18 20:41:19,021 [INFO] (32096 MainThread) [directoryHooksExecutor.py-29] [root directoryHooksExecutor info] Executing script: /opt/elasticbeanstalk/hooks/appdeploy/enact/99_reload_app_server.sh
2014-06-18 20:41:19,532 [INFO] (32096 MainThread) [directoryHooksExecutor.py-29] [root directoryHooksExecutor info] Output from script: =============== Phusion Passenger Standalone web server started ===============
PID file: /var/app/support/pids/passenger.pid
Log file: /var/app/support/logs/passenger.log
Environment: production
Accessible via: http://0.0.0.0/
Serving in the background as a daemon.
Problems? Check http://www.modrails.com/documentation/Users%20guide%20Standalone.html#troubleshooting
===============================================================================
注意成功迁移项目的最后一部分。