zoukankan      html  css  js  c++  java
  • Mac上配置 Ruby on Rails和Git

    Ruby on Rails on Mac
    ====================================================================================
    http://morizyun.github.io/blog/marvericks-rails-setup-ruby-rvm-msyql/
    for general : useful : http://qiita.com/keneo/items/0a58b188183b5100e3af
    for mysql : http://qiita.com/hkusu/items/cda3e8461e7a46ecf25d
    http://dev.classmethod.jp/server-side/language/build-ruby-environment-by-rbenv/
    1.安装Homebrew 
    $ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
    2.安装rbenv
    $brew install ruby-build
    $brew install rbenv
    设置path
    $ echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
    $ echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
    $ source .bash_profile
    3.安装可能用的工具,包
    3.1 安装sublime和配置用命令行打开 sublime
    https://gist.github.com/olivierlacan/1195304
    安装好sublime以后。在/usr/local/bin下面创建它的快捷方式,这样就能在不论什么地方都能运行subl来启动sublime
    $ln -s /Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl /usr/local/bin/sub
    3.2 装git
    $brew install git
    3.3 使用irb(interactive ruby)的包
    $ brew install readline
    3.4 安装使用https的包
    $ brew install openssl
    4.安装ruby
    $ rbenv install -l 确定能够安装的ruby
    $ rbenv install 2.1.4 安装要使用的版本号
    $ rbenv global 2.1.4 设定使用的版本号。假设不设置。直接ruby -v看到的可能是其它版本号
    $ rbenv versions 确认
    $ ruby -v 会显示ruby 2.1.4p265 (2014-10-27 revision 48166) [x86_64-darwin14.0]
    5.安装rails
    $ gem install rails
    $ gem install bundler
    $ rbenv rehash
    $ source ~/.bash_profile
    $ rails -v 会显示 rails 4.2.1
    6.安装 MySql
    $ brew update
    $ brew install mysql
    $ brew info mysql 确认,也能够mysql —version 仅仅看版本号号
    7.启动rails
    $ rails server
    打开http://localhost:3000确认是否成功
    Ctrl+c 退出
    8.使用MySql
    $ mysql.server start
    $ mysql -uroot 默认没有password 假设要设password运行下面语句
    $ mysql_secure_installation 
    $ mysql -uroot -p 带password
    mysql>exit 退出
    $ mysql.server stop
    9.第二次启动电脑后。运行rails -v 提示未安装,运行ruby -v显示的是2.0.0,运行rbenv global 2.1.4后还是不变。

    此时运行 $ echo 'eval "$(rbenv init -)"' >> ~/.bash_profile (把rbenv的初始化脚本写入该文件)(假设权限不够。改动该文件拥有者为用户) $ source ~/.bash_profile(运行该文件) 再运行ruby -v 和rails -v就能够了。 10.开发Ruby on Rails http://openbook4.me/projects/92 11. 创建工程及上传到github $git config --global user.name "username" $git config --global user.email email@example.com $git config --global core.editor "subl -w" //配置编辑器,这里是subl $subl ~/.netrc 追加下面 //假设不运行,每次push须要输入username和password machine github.com login USERNAME password PASSWORD $rails new larry-twitter //创建app $cd larry-twitter $ git init //会在app文件夹下创建git repo, larry-twitter $ git add . $ git commit -m "Initialize repository" 网页github上创建repository,获取https $ git remote add origin https://github.com/yangpeng-chn/larry-twitter.git $ git push -u origin master 假设bundle install失败(OpenSSl相关) 能够运行下面命令: RUBY_CONFIGURE_OPTS=--with-openssl-dir=/usr/local/Cellar/openssl/1.0.2h_1 rbenv install 1.9.3-p551 ===================================================================================

    
    
    
    
    
       
    
  • 相关阅读:
    【转】umount 的时候报错:device is busy
    【转】linux shell 的tr命令
    给bash的提示符设置不同的颜色
    备份系统时候出现错误
    [转]Xen 的漫漫人生路
    linux/screen的指令
    扩大centos镜像的硬盘空间
    ASP.NET Web API学习资源
    svn make a tag
    query多选下拉框插件 jquerymultiselect
  • 原文地址:https://www.cnblogs.com/clnchanpin/p/7039877.html
Copyright © 2011-2022 走看看