无法运行localhost:3000(Ubuntu 12.10)

时间:2013-04-09 01:44:35

标签: ruby-on-rails ubuntu localhost

我发现了一些与我相关的帖子......但现有的答案都没有...所以这里有一个来自Newbee的新帖子:

我刚刚安装了Ubuntu 12.10并尝试按照各种教程(http://rubyonrails.org/download)在rails上安装Ruby,我甚至尝试过RVM ......所以最后当我尝试启动我的服务器时我的localhost:3000不是工作

启动服务器时,这是我的终端:

laslo@ubuntu:~$ rails s
/usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require': iconv will be deprecated in the future, use String#encode instead.
/usr/lib/ruby/vendor_ruby/railties/lib/rails_generator/generators/applications/app/app_generator.rb:7: Use RbConfig instead of obsolete and deprecated Config.
      exists  
      exists  app/controllers
      exists  app/helpers
      exists  app/models
      exists  app/views/layouts
      exists  config/environments
      exists  config/initializers
      exists  config/locales
      exists  db
      exists  doc
      exists  lib
      exists  lib/tasks
      exists  log
      exists  public/images
      exists  public/javascripts
      exists  public/stylesheets
      exists  script/performance
      exists  test/fixtures
      exists  test/functional
      exists  test/integration
      exists  test/performance
      exists  test/unit
      exists  vendor
      exists  vendor/plugins
      exists  tmp/sessions
      exists  tmp/sockets
      exists  tmp/cache
      exists  tmp/pids
   identical  Rakefile
   identical  README
   identical  app/controllers/application_controller.rb
   identical  app/helpers/application_helper.rb
   identical  config/database.yml
   identical  config/routes.rb
   identical  config/locales/en.yml
   identical  db/seeds.rb
   identical  config/initializers/backtrace_silencers.rb
   identical  config/initializers/inflections.rb
   identical  config/initializers/mime_types.rb
   identical  config/initializers/new_rails_defaults.rb
overwrite config/initializers/session_store.rb? (enter "h" for help) [Ynaqdh] y
       force  config/initializers/session_store.rb
overwrite config/initializers/cookie_verification_secret.rb? (enter "h" for help) [Ynaqdh] y
       force  config/initializers/cookie_verification_secret.rb
   identical  config/environment.rb
   identical  config/boot.rb
   identical  config/environments/production.rb
   identical  config/environments/development.rb
   identical  config/environments/test.rb
   identical  script/about
   identical  script/console
   identical  script/dbconsole
   identical  script/destroy
   identical  script/generate
   identical  script/runner
   identical  script/server
   identical  script/plugin
   identical  script/performance/benchmarker
   identical  script/performance/profiler
   identical  test/test_helper.rb
   identical  test/performance/browsing_test.rb
   identical  public/404.html
   identical  public/422.html
   identical  public/500.html
   identical  public/index.html
   identical  public/favicon.ico
   identical  public/robots.txt
   identical  public/images/rails.png
   identical  public/javascripts/prototype.js
   identical  public/javascripts/effects.js
   identical  public/javascripts/dragdrop.js
   identical  public/javascripts/controls.js
   identical  public/javascripts/application.js
   identical  doc/README_FOR_APP
   identical  log/server.log
   identical  log/production.log
   identical  log/development.log
   identical  log/test.log
      exists  vendor/rails

有什么想法吗?当然,我错过了一些巨大的东西......但是又是什么?

4 个答案:

答案 0 :(得分:0)

Rails 3 +

从项目根目录尝试bundle exec script/rails server

e.g。

durrantm.../linker$ bundle exec script/rails server
=> Booting WEBrick
=> Rails 3.1.8 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2013-04-08 21:48:24] INFO  WEBrick 1.3.1
[2013-04-08 21:48:24] INFO  ruby 1.9.3 (2012-11-10) [i686-linux]
[2013-04-08 21:48:24] INFO  WEBrick::HTTPServer#start: pid=9187 port=3000

Rails 2

从项目根目录:

$ script/server
=> Booting WEBrick
=> Rails 2.3.8 application starting on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2013-04-08 21:58:11] INFO  WEBrick 1.3.1
[2013-04-08 21:58:11] INFO  ruby 1.9.3 (2012-11-10) [i686-linux]
[2013-04-08 21:58:11] INFO  WEBrick::HTTPServer#start: pid=10473 port=3000

如果失败,可能会重新开始:

cd                  # Go to your home directory
rails new abc       # Create the app
cd abc              # cd into the project's directory.
                    # Change the config/database.yml if desired.
script/rails server # for rails 3 or use the rails 2 command above.

更多版本信息:

Ruby,你应该是1.9.2+现在大多数人都在1.9.3+ 我建议您使用RVM来维护您的ruby版本。其他人也使用rbenv。

rvm:https://rvm.io/#是的,这是一个真实的网址! rbenv:https://github.com/sstephenson/rbenv/

你应该在轨道上的轨道3.1+检查rails -v
您可以使用gem install rails使用-v 3.1.2安装较新版本以指定该版本。

答案 1 :(得分:0)

Rails服务器适用于特定应用。您在根路径中启动了rails sever,当然这不起作用。

您首先需要创建一个新应用。

$ rails new myapp
$ cd myapp
# Install the gems needed at first
$ bundle install
# Then start server
$ rails s

添加

从您的代码中我发现真正的原因是您使用的是Ruby 1.9.1。您刚刚下载的最新Rails不支持此版本。

尝试至少将Ruby升级到1.9.3。

答案 2 :(得分:0)

什么是Ruby的版本?Ruby-v显示它?你应该在第一个这些命令时做。

bundle update
bundle install

答案 3 :(得分:0)

我和你有同样的问题,这就是我解决这个问题的方法。 在您创建的项目的CD中键入 script / server 。 我