mac 및 Liux 아래 ruby+rails 환경 구축

2979 단어 rubyrails
mac 는 보통 ruby 버 전의 ruby 환경 을 가지 고 다 닙 니 다.예 를 들 어 제 것 은 2.0.0 입 니 다.프로젝트 에 필요 한 버 전이 자신의 기본 버 전과 같다 면 다른 버 전 을 설치 하 는 것 을 괴 롭 히 지 않 아 도 된다.다 르 면 rvm 를 사용 하여 ruby 버 전 을 설치 하 는 것 을 소개 합 니 다.
rvm 설치(홈 페이지 http://www.rvm.io/ 참조)
첫 번 째 단 계 는 필수 가 아 닐 수도 있 습 니 다.
첫걸음
 gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB 
둘째 걸음
 curl -sSL https://get.rvm.io | bash -s stable 
성공 하면 보통 힌트 가 있어 요.
 Downloading https://github.com/rvm/rvm/archive/1.29.3.tar.gz Downloading https://github.com/rvm/rvm/releases/download/1.29.3/1.29.3.tar.gz.asc Found PGP signature at: 'https://github.com/rvm/rvm/releases/download/1.29.3/1.29.3.tar.gz.asc', but no GPG software exists to validate it, skipping. Installing RVM to /Users/echen1/.rvm/   Adding rvm PATH line to /Users/echen1/.profile /Users/echen1/.mkshrc /Users/echen1/.bashrc /Users/echen1/.zshrc.   Adding rvm loading line to /Users/echen1/.profile /Users/echen1/.bash_profile /Users/echen1/.zlogin. Installation of RVM in /Users/echen1/.rvm/ is almost complete:  * To start using RVM you need to run `source /Users/echen1/.rvm/scripts/rvm`   in all your open shell windows, in rare cases you need to reopen all shell windows.  * WARNING: '~/.profile' file found. To load it into your shell, add the following line to '/Users/echen1/.bash_profile': 
위 에 rvm 를 설치 한 후 마지막 두 번 째 줄 에 WARNING 이 있 습 니 다.이때 rvm 를 직접 실행 하면 command not found 솔 루 션 이 나타 날 수 있 습 니 다.명령 을 실행 하 십시오.
 source ~/.profile 
이 때 다시 실행:유사 한 결 과 는 설치 에 성 공 했 음 을 나타 낸다
 rvm -v 

image.png 스 위칭 소스
원생 의 기원 은 외국 에 있 기 때문에 보통 느 리 기 때문에 타 오 바 오 원 으로 전환 할 수 있다(참고:https://ruby.taobao.org/).
For mac
 sed -i .bak -E 's!https?://cache.ruby-lang.org/pub/ruby!https://ruby.taobao.org/mirrors/ruby!' $rvm_path/config/db 
For Linux
 sed -i -E 's!https?://cache.ruby-lang.org/pub/ruby!https://ruby.taobao.org/mirrors/ruby!' $rvm_path/config/db 
rvm 사용 안내 목록 에 알려 진 ruby 버 전
 rvm list known 
ruby 버 전
 rvm install 1.9.3 
설치
최신 1.9.3 이 설치 되 어 있 습 니 다.rvm list known 목록 에 있 는 것 은 모두 설치 할 수 있 습 니 다.
ruby 버 전
 rvm use 1.9.3 
을 기본 버 전
 rvm use 1.9.3 --default  
으로 설정 하여 설 치 된 ruby
 rvm list 
을 조회 합 니 다.
image.png
그림 에서 보 듯 이 전환 성공
rails 설치 방법 1(직접 설치)
 gem sources --add https://gems.ruby-china.org/ --remove https://rubygems.org/ 
방법 2
rails 프로젝트 가 있 으 면 프로젝트 에서 bundle install 을 실행 합 니 다.

좋은 웹페이지 즐겨찾기