1. 程式人生 > >Ubuntu作業系統下rbenv、ruby、rails開發環境搭建

Ubuntu作業系統下rbenv、ruby、rails開發環境搭建

  1. # ! /usr/bin/sh
  2. # Ubuntu系統下安裝ruby/rails必要的庫和編譯環境
  3. sudo apt-get update
  4. sudo apt-get install -y build-essential openssl curl libcurl3-dev libreadline6 libreadline6-dev git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libxml2-dev libxslt-dev autoconf automake libtool imagemagick libmagickwand-dev libpcre3-dev libsqlite3-dev
  5. # rbenv環境安裝
  6. git clone https://github.com/sstephenson/rbenv.git ~/.rbenv
  7. echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
  8. echo 'eval "$(rbenv init -)"' >> ~/.bashrc
  9. source ~/.bashrc
  10. type rbenv
  11. git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
  12. # ruby環境安裝,首先列出可安裝的版本,然後選擇後進行下載編譯
  13. rbenv install -l
  14. rbenv install 1.9.3-p448
  15. # 設定當前使用的ruby版本並將gem的源改為淘寶映象
  16. rbenv global 1.9.3-p448
  17. rbenv rehash
  18. gem sources --remove https://rubygems.org/
  19. gem sources -a http://ruby.taobao.org/
  20. # 安裝rails
  21. gem install bundler rails
  22. # 檢查安裝後的軟體版本
  23. ruby -v
  24. gem -v
  25. rake -V
  26. rails -v
  27. # 安裝JAVA
  28. sudo add-apt-repository ppa:webupd8team/java
  29. sudo apt-get update
  30. sudo apt-get install oracle-java6-installer
  31. # 升級
  32. #sudo update-java-alternatives -s java-6-oracle
  33. # 設定JAVA環境變數
  34. sudo apt-get install oracle-java6-set-default
  35. # 設定JAVA字元
  36. sudo mkdir /usr/lib/jvm/java-6-oracle/jre/lib/fonts/fallback
  37. cd /usr/lib/jvm/java-6-oracle/jre/lib/fonts/fallback
  38. sudo ln -s /usr/share/fonts/truetype/wqy/wqy-microhei.ttc wqy-microhei.ttf
  39. sudo ln -s /usr/share/fonts/truetype/wqy/wqy-zenhei.ttc wqy-zenhei.ttf
  40. # 安裝node.js(已經包含npm)
  41. sudo add-apt-repository ppa:chris-lea/node.js
  42. sudo apt-get update
  43. sudo apt-get install nodejs