Skip to content

Instantly share code, notes, and snippets.

@ozooxo
Last active August 29, 2015 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ozooxo/9b655b8ccf383bbd8836 to your computer and use it in GitHub Desktop.
Save ozooxo/9b655b8ccf383bbd8836 to your computer and use it in GitHub Desktop.
在中国大陆境内安装配置ruby on rails

基本上按照 https://gorails.com/setup/ubuntu/14.04 的安装方法是可以的。

第一个遇到的问题是 gem install rails 报错

ERROR: Could not find a valid gem 'watir' (>= 0), here is why:
Unable to download data from https://rubygems.org/ - SSL_connect retur
ned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed (
https://s3.amazonaws.com/production.s3.rubygems.org/latest_specs.4.8.gz)

虽然按照 https://github.com/rubygems/rubygems/issues/515 的说法这是rubygems的问题,但是其实是因为中国大陆地区屏蔽amazon s3。方法是把gems的源换成 ruby.taobao.org

gem sources --remove https://rubygems.org/
gem sources -a https://ruby.taobao.org/

此外执行 rails new my_app 的时候,可能会在 run bundle install 那里卡很久。需要的话可以 bundle install 一下。另外如果报错可能需要手动删除 my_app 文件夹下面的 Gemfile.lock 。此外有时候 rails server 报错,那是因为终止server应该用Ctrl-C(而不是终止运行的比如Ctrl-Z)。如果发生,重启terminal就能解决。

最后rails可以通过 http://localhost:3000/ 或者 http://0.0.0.0:3000/ 连接。

我使用Ubuntu 14.04。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment