反馈 把我安装 ruby-china 的详细步骤发上来,寻求问题解决

bindiry · 2011年11月10日 · 最后由 feitian124 回复于 2012年06月06日 · 9454 次阅读

系统:ubuntu 11.10 ruby 版本:1.9.2 rails 版本:3.1.1 mongodb 版本:2.0.1 redis 版本:2.4.2

全部从全新系统开始,搞了两遍,依然没有解决,以下是我的安装步骤:


基本设置及常用软件安装

# 建立程序安装目录
$ cd ~
$ mkdir apps
# 建立工作目录
$ cd ~
$ mkdir workspace
# 安装常用库及软件
$ sudo apt-get install git git-core vim curl libxml2-dev libxslt-dev make gcc g++

Ruby on Rails 安装

1.Ruby install

$ sudo apt-get install ruby1.9.2-full
# 查看当前系统ruby版本
$ ruby -v
# ruby 1.9.2p290 (2011-07-09 revision 32553) [i686-linux]

2.Gem update

$ sudo gem install rubygems-update
$ sudo update_rubygems
$ gem -v
# 1.8.11

# 将下面语句写入~/.gemrc 禁止Gem安装本地文档
gem: --no-ri --no-rdoc```

3.Rails install
```bash
$ sudo gem install rails
$ rails -v
# Rails 3.1.1

4.Other install

$ sudo apt-get install sqlite3 libsqlite3-dev
$ sudo gem install sqlite3-ruby

MongoDB 安装

1.install

$ cd ~/apps
$ wget http://fastdl.mongodb.org/linux/mongodb-linux-i686-2.0.1.tgz
$ tar xzf mongodb-linux-i686-2.0.1.tgz
$ sudo ln -s ~/apps/mongodb-linux-i686-2.0.1/bin/mongod /usr/bin/mongod
$ sudo ln -s ~/apps/mongodb-linux-i686-2.0.1/bin/mongo /usr/bin/mongo
# create data directory
$ sudo mkdir -p /data/db
# set permission
$ sudo chmod 755 -R /data/db
  1. run server bash $ sudo mongod # 如果数据库目录不想建立在/data/db,可以用--dbpath参数指定目录

3.test

$ mongo
> db.foo.save( { a : 1 } )
> db.foo.find()

Redis 安装

  1. install

    $ cd ~/apps
    $ wget http://redis.googlecode.com/files/redis-2.4.2.tar.gz
    $ tar xzf redis-2.4.2.tar.gz
    $ cd redis-2.4.2
    $ sudo make
    $ sudo make install
    
  2. run server

    $ sudo src/redis-server
    
  3. test

    $ sudo src/redis-cli
    redis> set foo bar
    OK
    redis> get foo
    "bar"
    

安装 ruby-china 1.Node.js install

$ sudo apt-get install libssl-dev apache2-utils
$ cd ~/workspace
$ git clone git://github.com/ry/node.git
$ cd node
$ ./configure
$ make
$ sudo make install
  1. Deploy ruby-china bash $ sudo gem install thin execjs therubyracer $ sudo gem install nokogiri -v '1.5.0' $ cd ~/workspace $ git clone https://github.com/huacnlee/ruby-china.git $ cd ruby-china $ cp config/config.yml.default config/config.yml $ cp config/mongoid.yml.default config/mongoid.yml $ cp config/redis.yml.default config/redis.yml $ sudo bundle install $ sudo rake assets:precompile $ thin start -O -C config/thin.yml $ ./script/resque start

运行到最后第三部(sudo rake assets:precompile)时,出现问题如下:

bindiry@bindiry-ubuntu:~/workspace/ruby-china$ sudo rake assets:precompile
rake aborted!
Failed to connect to a master node at 127.0.0.1:27017

Tasks: TOP => environment
(See full trace by running task with --trace)
rake aborted!
Command failed with status (1): [/usr/bin/ruby1.9.1 /usr/bin/rake assets:pr...]

Tasks: TOP => assets:precompile
(See full trace by running task with --trace)
bindiry@bindiry-ubuntu:~/workspace/ruby-china$ sudo rake assets:precompile
rake aborted!
uninitialized constant AWS

Tasks: TOP => environment
(See full trace by running task with --trace)
rake aborted!
Command failed with status (1): [/usr/bin/ruby1.9.1 /usr/bin/rake assets:pr...]

之前已经发过帖子 http://ruby-china.org/topics/55 里面@huacnlee @cqpx @Rei 给出的介绍方法均尝试过,都没有解决,所以开个新帖,把我的操作步骤仔细说一下,哪位同学帮我解决一下?

uninitialized constant AWS...我在我电脑上试试

可能帮不上你什么忙了。。我这里编 assets 和启动服务器都没有问题。。

不知道是不是你用 sudo 的关系,因为我都没用速多。 不加 sudo 试试。 先

bundle pack

然后

rake assets:precompile

#3 楼 @cqpx 非常感谢 cqpx 的回复,我刚下载了 ubuntu-server,这次我直接用 root 来搞一下看看。

#5 楼 @Rei 好的,这次在 ubuntu server 里安装就试试这个

@Rei @cqpx

悲剧了,换上 ubuntu server,用 root 用户,mongodb 也用的 deb 版安装,还是出同样的错误。。。 郁闷了。。

root@ubuntu-server:~/workspace/ruby-china# rake assets:precompile
:public is no longer used to avoid overloading Module#public, use :public_folder instead
        from /usr/lib/ruby/gems/1.9.1/gems/resque-1.19.0/lib/resque/server.rb:12:in `<class:Server>'
/usr/bin/ruby1.9.1 /usr/bin/rake assets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets
:public is no longer used to avoid overloading Module#public, use :public_folder instead
        from /usr/lib/ruby/gems/1.9.1/gems/resque-1.19.0/lib/resque/server.rb:12:in `<class:Server>'
rake aborted!
Connection refused - Unable to connect to Redis on 127.0.0.1:6379

Tasks: TOP => environment
(See full trace by running task with --trace)
rake aborted!
Command failed with status (1): [/usr/bin/ruby1.9.1 /usr/bin/rake assets:pr...]

Tasks: TOP => assets:precompile
(See full trace by running task with --trace)

#7 楼 @bindiry 这次是你的 Redis 没装好,mongodb 没问题了

我觉得没啥特别理由还是用软件包控制器来安装组件吧

#8 楼 @Los

确定 mongodb 和 redis 都没问题后的结果。。。

root@ubuntu-server:~/workspace/ruby-china# rake assets:precompile
:public is no longer used to avoid overloading Module#public, use :public_folder instead
        from /usr/lib/ruby/gems/1.9.1/gems/resque-1.19.0/lib/resque/server.rb:12:in `<class:Server>'
/usr/bin/ruby1.9.1 /usr/bin/rake assets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets
:public is no longer used to avoid overloading Module#public, use :public_folder instead
        from /usr/lib/ruby/gems/1.9.1/gems/resque-1.19.0/lib/resque/server.rb:12:in `<class:Server>'
rake aborted!
uninitialized constant AWS

Tasks: TOP => environment
(See full trace by running task with --trace)
rake aborted!
Command failed with status (1): [/usr/bin/ruby1.9.1 /usr/bin/rake assets:pr...]

#9 楼 @Rei 关键是我不知道该装哪些组件。。。 为啥最后这个错误信息会有个 uninitialized constant AWS 难道用了 AWS 的服务?

#11 楼 @bindiry 用 AWS 来发邮件了。把这个文件删掉试试。config/initializers/setup_mailer.rb @重庆

#12 楼 @cqpx 非常感谢 cqpx,就是这个的问题,成功运行起来了

建议搭建生产服务器的时候,能编译安装的 就编译安装,虽然可能浪费点时间,但是时间久了,你就会体会到好处了!!!

这个 ubuntu 安装有点..... 给后面看到的提个醒

  1. sudo 能不用就别用,后面都是麻烦,特别是 rvm 的
  2. 初学的自己调试的,真不用编译安装,等你有生产环境再担心生产环境的事。(和过早优化,过早重构一个道理)
  3. 最后那个 precompile,版本不一致,要把 sudo 换成 bundle exec,通常建议加个 alias be,这个有多个项目的时候,经常会用到。

开发环境在 ubuntu 下配好了,简单看看还挺好的,回头去 mac 下再配一下,然后,看看有什么 issue 可以接。

你把系统环境重新安装,Ruby 用 RVM 来安装,MongoDB, Redis 用 http://github.com/huacnlee/init.d 来安装(Ubuntu Server 9.04)

#16 楼 @huacnlee 好东西,谢谢分享,我之前安装 ruby-china 也出错,怀疑是 MongoDB 没装好,现在全部卸载重装,希望能行 XD

重装了 MongoDB 和 Redis 后重新安装初始化 ruby-china 项目在最后两步遇到问题

zernel@zernel:~/workspace/rails/ruby-china$ rake assets:precompile
:public is no longer used to avoid overloading Module#public, use :public_folder instead
    from /home/zernel/.rvm/gems/ruby-1.9.2-p290@ruby-china/gems/resque-1.19.0/lib/resque/server.rb:12:in `<class:Server>'
/home/zernel/.rvm/rubies/ruby-1.9.2-p290/bin/ruby /home/zernel/.rvm/gems/ruby-1.9.2-p290@ruby-china/bin/rake assets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets
:public is no longer used to avoid overloading Module#public, use :public_folder instead
    from /home/zernel/.rvm/gems/ruby-1.9.2-p290@ruby-china/gems/resque-1.19.0/lib/resque/server.rb:12:in `<class:Server>'
MONGODB [WARNING] Please note that logging negatively impacts client-side performance. You should set your logging level no lower than :info in production.
MONGODB admin['$cmd'].find({:ismaster=>1}).limit(-1)
MONGODB ruby_china['system.namespaces'].find({})
MONGODB ruby_china['site_configs'].find({:key=>"index_html"}).limit(-1).sort([[:_id, :asc]])
MONGODB ruby_china['site_configs'].find({:key=>"wiki_index_html"}).limit(-1).sort([[:_id, :asc]])
MONGODB ruby_china['site_configs'].find({:key=>"footer_html"}).limit(-1).sort([[:_id, :asc]])
MONGODB ruby_china['site_configs'].find({:key=>"after_topic_html"}).limit(-1).sort([[:_id, :asc]])
MONGODB ruby_china['site_configs'].find({:key=>"before_topic_html"}).limit(-1).sort([[:_id, :asc]])
MONGODB ruby_china['site_configs'].find({:key=>"topic_index_sidebar_html"}).limit(-1).sort([[:_id, :asc]])
MONGODB ruby_china['site_configs'].find({:key=>"site_index_html"}).limit(-1).sort([[:_id, :asc]])
/home/zernel/.rvm/rubies/ruby-1.9.2-p290/bin/ruby /home/zernel/.rvm/gems/ruby-1.9.2-p290@ruby-china/bin/rake assets:precompile:nondigest RAILS_ENV=production RAILS_GROUPS=assets
:public is no longer used to avoid overloading Module#public, use :public_folder instead
    from /home/zernel/.rvm/gems/ruby-1.9.2-p290@ruby-china/gems/resque-1.19.0/lib/resque/server.rb:12:in `<class:Server>'
MONGODB [WARNING] Please note that logging negatively impacts client-side performance. You should set your logging level no lower than :info in production.
MONGODB admin['$cmd'].find({:ismaster=>1}).limit(-1)
MONGODB ruby_china['system.namespaces'].find({})
MONGODB ruby_china['site_configs'].find({:key=>"index_html"}).limit(-1).sort([[:_id, :asc]])
MONGODB ruby_china['site_configs'].find({:key=>"wiki_index_html"}).limit(-1).sort([[:_id, :asc]])
MONGODB ruby_china['site_configs'].find({:key=>"footer_html"}).limit(-1).sort([[:_id, :asc]])
MONGODB ruby_china['site_configs'].find({:key=>"after_topic_html"}).limit(-1).sort([[:_id, :asc]])
MONGODB ruby_china['site_configs'].find({:key=>"before_topic_html"}).limit(-1).sort([[:_id, :asc]])
MONGODB ruby_china['site_configs'].find({:key=>"topic_index_sidebar_html"}).limit(-1).sort([[:_id, :asc]])
MONGODB ruby_china['site_configs'].find({:key=>"site_index_html"}).limit(-1).sort([[:_id, :asc]])
zernel@zernel:~/workspace/rails/ruby-china$ thin start -O -C config/thin.yml
/usr/lib/ruby/1.8/optparse.rb:1450:in `complete': invalid option: -O (OptionParser::InvalidOption)
    from /usr/lib/ruby/1.8/optparse.rb:1448:in `catch'
    from /usr/lib/ruby/1.8/optparse.rb:1448:in `complete'
    from /usr/lib/ruby/1.8/optparse.rb:1287:in `parse_in_order'
    from /usr/lib/ruby/1.8/optparse.rb:1254:in `catch'
    from /usr/lib/ruby/1.8/optparse.rb:1254:in `parse_in_order'
    from /usr/lib/ruby/1.8/optparse.rb:1248:in `order!'
    from /usr/lib/ruby/1.8/optparse.rb:1339:in `permute!'
    from /usr/lib/ruby/1.8/optparse.rb:1360:in `parse!'
    from /usr/lib/ruby/1.8/thin/runner.rb:131:in `parse!'
    from /usr/lib/ruby/1.8/thin/runner.rb:47:in `initialize'
    from /usr/bin/thin:6:in `new'
    from /usr/bin/thin:6`

请问有人知道是什么问题吗,谢谢

额 ...直接跳过那一步不管能直接在服务器打开了...

#18 楼 @Zernel 不要用 thin 启动用 rails s 启动 @huacnlee 能不能出来给大家答下疑呢

管理员账户怎么设置啊?没弄懂

#21 楼 @inetufo 配置文件里有配置 admin 的 mail 帐号~

#21 楼 @inetufo 我是跳过那一步直接用 rails s 启动,应该不会有什么影响吧

#22 楼 @iceskysl 谢谢,已经解决了

#23 楼 @Zernel 不会有影响,这样默认启动的是 development 模式

#25 楼 @inetufo 好的,谢谢 XD

1.9.1 omg~~ > 1.9.2~

#7 楼 @bindiry 这个 refused 的问题,有解么? `MONGODB ruby_china['system.namespaces'].find({}) MONGODB ruby_china['site_configs'].find({:key=>"index_html"}).limit(-1).sort([[:_id, :asc]]) MONGODB ruby_china['site_configs'].find({:key=>"wiki_index_html"}).limit(-1).sort([[:_id, :asc]]) MONGODB ruby_china['site_configs'].find({:key=>"footer_html"}).limit(-1).sort([[:_id, :asc]]) MONGODB ruby_china['site_configs'].find({:key=>"after_topic_html"}).limit(-1).sort([[:_id, :asc]]) MONGODB ruby_china['site_configs'].find({:key=>"before_topic_html"}).limit(-1).sort([[:_id, :asc]]) MONGODB ruby_china['site_configs'].find({:key=>"topic_index_sidebar_html"}).limit(-1).sort([[:_id, :asc]]) MONGODB ruby_china['site_configs'].find({:key=>"site_index_html"}).limit(-1).sort([[:_id, :asc]]) rake aborted! Connection refused - Unable to connect to Redis on 127.0.0.1:6379

Tasks: TOP => environment (See full trace by running task with --trace) rake aborted! Command failed with status (1): [~/.rvm/rubies/ruby-1.9.2-p290/bin/...]

Tasks: TOP => assets:precompile (See full trace by running task with --trace)`

#28 楼 @kjpioo Redis 装好了么?

#29 楼 @southwolf 是这样的输出,说明 redis 是安装好了 ~$ redis-server [6880] 08 Jan 19:17:58 # Warning: no config file specified, using the default config. In order to specify a config file use 'redis-server /path/to/redis.conf' [6880] 08 Jan 19:17:58 * Server started, Redis version 2.4.5 [6880] 08 Jan 19:17:58 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect. [6880] 08 Jan 19:17:58 * The server is now ready to accept connections on port 6379 [6880] 08 Jan 19:17:59 - 0 clients connected (0 slaves), 547464 bytes in use [6880] 08 Jan 19:18:04 - 0 clients connected (0 slaves), 547464 bytes in use

遇到和你一样的问题,这个 assets 的问题影响不大。我跳过这一步后遇到了另一个问题,即是在运行./script/resque start 时报错了:

MONGODB [WARNING] Please note that logging negatively impacts client-side performance. You should set your logging level no lower than :info in production. /home/administrator/.rvm/gems/ruby-1.9.2-p290/gems/mongo-1.5.2/lib/mongo/connection.rb:413:in `connect': Failed to connect to a master node at 127.0.0.1:27017 (Mongo::ConnectionFailure) 我去 stackoverflow.com 里去查过。在 mongdb 官网去查过,到 mongoid 去查过,直接在 google 里也查过,硬是没找到解决办法.... 有没有谁知道这个应该怎么弄?

我将出现这个 mongodb warning 的问题提交到 github.com 了,希望能有找到解决办法。 https://github.com/huacnlee/ruby-china/issues/175

#31 楼 @suffering Failed to connect to a master node at 127.0.0.1:27017 (Mongo::ConnectionFailure) MongoDB 没有启动

好吧,问题诡异地得到了解决。我所做的事情,就是重新运行起 mongodb,与 redis,并保持其持续运行。在运行rake assets:precompile./script/resque start时虽然依旧出现了set your logging level no lower than :info in production,但是,却是不影响其运行。

谢谢了,现在运行良好~~ 看 ruby-china.org,我得把我没接触过的第三方支持好好了解解一下... #_# 漫漫菜鸟路~~~

#35 楼 @suffering 注意仔细看错误提示一般就能发现问题所在

#16 楼 @huacnlee 真的是好东西~

匿名 #38 2012年01月10日

其实 @huacnleehttp://github.com/huacnlee/init.d 挺管用的,再加上 rvm,很容易安装的呀。

@huacnlee @bindiry 请问你们装 mongodb, redis 等时是用 root 用户么 我现在 ubuntu 下只知道用 apt-get 装,否则各种权限问题。。

emerson Ruby-China 完整布署步骤和方法 提及了此话题。 04月03日 10:57
需要 登录 后方可回复, 如果你还没有账号请 注册新账号