Mac上配置 Ruby on Rails和Git

来源:互联网 发布:先导爱知见新导刻小说 编辑:程序博客网 时间:2024/06/10 19:28
Ruby on Rails on Mac====================================================================================http://morizyun.github.io/blog/marvericks-rails-setup-ruby-rvm-msyql/for general : useful : http://qiita.com/keneo/items/0a58b188183b5100e3affor mysql : http://qiita.com/hkusu/items/cda3e8461e7a46ecf25dhttp://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_profile3.安装可能用的工具,包3.1 安装sublime和配置用命令行打开 sublimehttps://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/sub3.2 装git$brew install git3.3 使用irb(interactive ruby)的包$ brew install readline3.4 安装使用https的包$ brew install openssl4.安装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.16.安装 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 默认没有密码 如果要设密码执行以下语句$ mysql_secure_installation $ mysql -uroot -p 带密码mysql>exit 退出$ mysql.server stop9.第二次启动电脑后,执行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 Railshttp://openbook4.me/projects/9211. 创建工程及上传到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和passwordmachine github.comlogin USERNAMEpassword 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===================================================================================
                                             
0 0
原创粉丝点击