我对使用 Ruby on Rails 运行网站非常陌生。一点背景故事:
所以我正在做一个项目,并且我已经获得了该网站的代码。我正在运行 Windows,所以我知道它不是 RoR 的最佳操作系统,但切换到不同的操作系统对我来说是最后的手段。
我从 railsinstaller.org 获得了 RailsInstaller,然后运行了它。一切安装顺利。
我bundle install
从我的站点目录中运行,遇到了 gem "therubyracer" 的问题。做了一堆搜索,发现Windows不需要gem。我认为。所以我将 Gemfile 中的 gem 注释掉,然后bundle install
再次运行。一切安装正常。
我尝试rails s
通过命令提示符运行并收到错误:
The program can't start because LIBMYSQL.dll is missing from your computer.
所以我对此做了一些研究,发现我必须将文件复制到 RailsInstaller 目录下的 Ruby/bin 文件夹中。错误消失了。
最后我又跑rails s
了,服务器放到了localhost下。我认为。无论如何,我去localhost:3000
并收到了 MySQL2::Error 和Can't connect to MySQL server on 'localhost' (10061)
. 当我点击Full Trace
我得到代码:
development/ruby/1.9.1/gems/mysql2-0.3.11-x86-mingw32/lib/mysql2/client.rb:44:in `connect'
development/ruby/1.9.1/gems/mysql2-0.3.11-x86-mingw32/lib/mysql2/client.rb:44:in `initialize'
development/ruby/1.9.1/gems/activerecord-3.2.3/lib/active_record/connection_adapters/mysql2_adapter.rb:16:in `new'
development/ruby/1.9.1/gems/activerecord-3.2.3/lib/active_record/connection_adapters/mysql2_adapter.rb:16:in `mysql2_connection'
development/ruby/1.9.1/gems/activerecord-3.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:303:in `new_connection'
development/ruby/1.9.1/gems/activerecord-3.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:313:in `checkout_new_connection'
development/ruby/1.9.1/gems/activerecord-3.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:237:in `block (2 levels) in checkout'
development/ruby/1.9.1/gems/activerecord-3.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:232:in `loop'
development/ruby/1.9.1/gems/activerecord-3.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:232:in `block in checkout'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
development/ruby/1.9.1/gems/activerecord-3.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:229:in `checkout'
development/ruby/1.9.1/gems/activerecord-3.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:95:in `connection'
development/ruby/1.9.1/gems/activerecord-3.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:398:in `retrieve_connection'
development/ruby/1.9.1/gems/activerecord-3.2.3/lib/active_record/connection_adapters/abstract/connection_specification.rb:168:in `retrieve_connection'
development/ruby/1.9.1/gems/activerecord-3.2.3/lib/active_record/connection_adapters/abstract/connection_specification.rb:142:in `connection'
development/ruby/1.9.1/gems/activerecord-3.2.3/lib/active_record/query_cache.rb:67:in `rescue in call'
development/ruby/1.9.1/gems/activerecord-3.2.3/lib/active_record/query_cache.rb:61:in `call'
development/ruby/1.9.1/gems/activerecord-3.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:467:in `call'
development/ruby/1.9.1/gems/actionpack-3.2.3/lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
development/ruby/1.9.1/gems/activesupport-3.2.3/lib/active_support/callbacks.rb:405:in `_run__132547094__call__984979790__callbacks'
development/ruby/1.9.1/gems/activesupport-3.2.3/lib/active_support/callbacks.rb:405:in `__run_callback'
development/ruby/1.9.1/gems/activesupport-3.2.3/lib/active_support/callbacks.rb:385:in `_run_call_callbacks'
development/ruby/1.9.1/gems/activesupport-3.2.3/lib/active_support/callbacks.rb:81:in `run_callbacks'
development/ruby/1.9.1/gems/actionpack-3.2.3/lib/action_dispatch/middleware/callbacks.rb:27:in `call'
development/ruby/1.9.1/gems/actionpack-3.2.3/lib/action_dispatch/middleware/reloader.rb:65:in `call'
development/ruby/1.9.1/gems/actionpack-3.2.3/lib/action_dispatch/middleware/remote_ip.rb:31:in `call'
development/ruby/1.9.1/gems/actionpack-3.2.3/lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call'
development/ruby/1.9.1/gems/actionpack-3.2.3/lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
development/ruby/1.9.1/gems/railties-3.2.3/lib/rails/rack/logger.rb:26:in `call_app'
development/ruby/1.9.1/gems/railties-3.2.3/lib/rails/rack/logger.rb:16:in `call'
development/ruby/1.9.1/gems/actionpack-3.2.3/lib/action_dispatch/middleware/request_id.rb:22:in `call'
development/ruby/1.9.1/gems/rack-1.4.1/lib/rack/methodoverride.rb:21:in `call'
development/ruby/1.9.1/gems/rack-1.4.1/lib/rack/runtime.rb:17:in `call'
development/ruby/1.9.1/gems/activesupport-3.2.3/lib/active_support/cache/strategy/local_cache.rb:72:in `call'
development/ruby/1.9.1/gems/rack-1.4.1/lib/rack/lock.rb:15:in `call'
development/ruby/1.9.1/gems/actionpack-3.2.3/lib/action_dispatch/middleware/static.rb:62:in `call'
development/ruby/1.9.1/gems/railties-3.2.3/lib/rails/engine.rb:479:in `call'
development/ruby/1.9.1/gems/railties-3.2.3/lib/rails/application.rb:220:in `call'
development/ruby/1.9.1/gems/rack-1.4.1/lib/rack/content_length.rb:14:in `call'
development/ruby/1.9.1/gems/railties-3.2.3/lib/rails/rack/log_tailer.rb:14:in `call'
development/ruby/1.9.1/gems/rack-1.4.1/lib/rack/handler/webrick.rb:59:in `service'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/webrick/httpserver.rb:138:in `service'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/webrick/httpserver.rb:94:in `run'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/webrick/server.rb:191:in `block in start_thread'
我对此进行了一些研究,发现Rails development - Can't connect to MySQL server on 'localhost' (10061)。
当我尝试ping localhost
使用命令提示符时,我得到了最上面的评论:
Reply from ::1: time<1ms
而且我不确定如何更改配置以使主机成为 127.0.0.1。
抱歉,这有点长,我不确定它有多大帮助。正如我在标题中所说,我对此很陌生 - 我仍然不确定 ahost
是什么。
我真的只想让网站运行起来,这样我终于可以开始工作了。我做的一切都正确吗?我真的需要therubyracer
吗?我做了什么/没有做哪些可以帮助我开始的事情?错误显示什么问题?
如果还有什么我需要提供的,请告诉我!谢谢您的帮助!