部署 Windows7 下的 rails/heroku/git 安装及配置流水

dongxf · 2012年10月24日 · 最后由 neverlandxy_naix 回复于 2012年10月24日 · 5289 次阅读

俺也是 rails 小白,不是来显丑的, 看到http://ruby-china.org/topics/6011 提供给 mayday 做参考。

==========运行环境设置==========

I.安装相关软件 1.检查 heroku rails3 的准备 https://devcenter.heroku.com/articles/rails3#prerequisites #支持 rubyRuby 1.9.2, Rubygems, Bundler, and Rails 3. 2.下载并安装 ruby1.9.2 http://rubyforge.org/frs/download.php/75127/rubyinstaller-1.9.2-p290.exe #安装包,钩选所有选项 (安装 Tk 库/路径/??) 3.安 Gems Bundler cmd>gem update --system ##已经存在 gem,更新为 1.8.24 cmd>gem install bundler #安装 bundler,安装为 1.1.5 4.下载并安装 DevKit http://www.rubyinstaller.org/downloads https://github.com/downloads/oneclick/rubyinstaller/DevKit-tdm-32-4.5.2-20111229-1559-sfx.exe #Extract DevKit to path d:\Ruby192\DevKit cmd>cd d:\Ruby192\DevKit cmd>ruby dk.rb init cmd>ruby dk.rb review cmd>ruby dk.rb install 5.安装 rails3 cmd>gem install rails ..... unable to convert U+00A9 from UTF-8 to GBK for lib/rdoc/text.rb, skipping ..... 6.安装 Heroku toolbelt https://toolbelt.herokuapp.com/ #发现人家已经自带 ruby1.9.2 和 git 了,安装于 c:\program files\ruby-1.9.2\目录下 cmd>ren c:\program files\ruby-1.9.2\ruby-1.9.2_heroku\ cmd>mklink /d c:\program files\ruby-1.92. d:\ruby192 cmd>ruby -rubygems -e "require 'rdiscount'; puts RDiscount.new('Hello RubyInstaller').to_html" #运行正常 7.安装 sliqte3 命令行工具 sqlite-dll-win32-x86-3071401.zip 和 sqlite-shell-win32-x86-3071401.zip http://sqlite.org/download.html #copy sqlite3.def sqlite3.dll sqlite3.exe to d:\ruby192\bin\ 8.这时候桌面上应该有三个,git bash "git>", ruby "cmd>" , iruby "irb>", modify ruby working directory

II. 配置 GIT,生成 SSH Key,上传到 github 和 Heroku

  1. 生成 SSH Key git>cd ~/.ssh git>ls #是空的 git>ssh-keygen -t rsa -C "dongxfatgmaildotcom" passcode:就不告诉你 Your identification has been saved in /c/Users/dongxf/.ssh/id_rsa Your public key has been saved in /c/Users/dongxf/.ssh/id_rsa.pub The key fingerprint is: ec:74:xx:8b:xx:36:xx:79:5f:xx:41:91:6d:1c:87:63 dongxfatgmaildotcom 2.上传到 github git>cd ~/.ssh git>clip < ~/.ssh/id_rsa.pub web>add ssh key in setting section #in http://www.github.com/ 3.上传 public key 到 Heroku cmd>cd C:\Documents and Settings\dongxf.ssh cmd>heroku keys:add ./id_rsa.pub 4.配置用户名,密码 cmd>git config --global user.name "Franklin Dong" cmd>git config --global user.email "dongxfatgmaildotcom" 5.测试 web>GitHub 中创建新的 repository,得到两种地址 (http/ssh) cmd>git clone git://github.com/heroku/ruby-sample.git cmd>cd ruby-sample.git cmd>git remote add sshdemo [email protected]:dongxf/demo.git #Using SSH key code here cmd>git remote add httpdemo https://github.com/dongxf/demo.git cmd>git push -u httpdemo master cmd>copy con: balhabalha #bala bala bala cmd>git add . cmd>git commit -m "modified" cmd>git push -u httpdemo master #都可以。将.ssh 备份到 workspace/dongxf/.ssh.zip

III. Hello, Rails 1.验证本地 rails 安装 cmd>rails new hello cmd>cd hello cmd>rails generate controller say hello bye cmd>rails generate scaffold post title:string body:text created:datetime cmd>rake db:migrate #creating table posts cmd>rails server -p 1008 cmd>start http://127.0.0.1:1008/ cmd>start http://127.0.0.1:1008/say/hello cmd>start http://127.0.0.1:1008/posts #保存初始版本 cmd>git init cmd>git add . cmd>git commit -m "init" cmd>git tag v1.0

3.Hello, Heroku, Modified from sqlite3 to posgresql cmd>gvim Gemfile #'sqlite'->'pg' #参考https://devcenter.heroku.com/articles/rails3 cmd>gvim config/database.yml #'sqlite3'->'postgresql' 'test.sqlite3'->'hello_test' cmd>bundle install cmd>git add . cmd>git commit -m "heroku" cmd>git tag v1.2 #cmd>heroku login #用 dongxfatgmaildotcom 登陆 Heroku cmd>heroku create cmd>git push heroku master #pushing branch 'master' to heroku repository cmd>heroku run rake db:migrate #初始化远端数据库 cmd>start http://pacific-journey-1108.herokuapp.com/ cmd>start http://pacific-journey-1108.herokuapp.com/say/hello cmd>start http://pacific-journey-1108.herokuapp.com/say/bye cmd>start http://pacific-journey-1108.herokuapp.com/posts

lz 用 markdown 排一下版吧

windows 下有 railsinstaller,一键安装即可,不需要 LZ 这么麻烦。

需要 登录 后方可回复, 如果你还没有账号请 注册新账号