Ubuntu作業系統下rbenv、ruby、rails開發環境搭建
阿新 • • 發佈:2019-02-18
- # ! /usr/bin/sh
- # Ubuntu系統下安裝ruby/rails必要的庫和編譯環境
- sudo apt-get update
- 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
- # rbenv環境安裝
- git clone https://github.com/sstephenson/rbenv.git ~/.rbenv
- echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
- echo 'eval "$(rbenv init -)"' >> ~/.bashrc
- source ~/.bashrc
- type rbenv
- git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
- # ruby環境安裝,首先列出可安裝的版本,然後選擇後進行下載編譯
- rbenv install -l
- rbenv install 1.9.3-p448
- # 設定當前使用的ruby版本並將gem的源改為淘寶映象
- rbenv global 1.9.3-p448
- rbenv rehash
- gem sources --remove https://rubygems.org/
- gem sources -a http://ruby.taobao.org/
- # 安裝rails
- gem install bundler rails
- # 檢查安裝後的軟體版本
- ruby -v
- gem -v
- rake -V
- rails -v
- # 安裝JAVA
- sudo add-apt-repository ppa:webupd8team/java
- sudo apt-get update
- sudo apt-get install oracle-java6-installer
- # 升級
- #sudo update-java-alternatives -s java-6-oracle
- # 設定JAVA環境變數
- sudo apt-get install oracle-java6-set-default
- # 設定JAVA字元
- sudo mkdir /usr/lib/jvm/java-6-oracle/jre/lib/fonts/fallback
- cd /usr/lib/jvm/java-6-oracle/jre/lib/fonts/fallback
- sudo ln -s /usr/share/fonts/truetype/wqy/wqy-microhei.ttc wqy-microhei.ttf
- sudo ln -s /usr/share/fonts/truetype/wqy/wqy-zenhei.ttc wqy-zenhei.ttf
- # 安裝node.js(已經包含npm)
- sudo add-apt-repository ppa:chris-lea/node.js
- sudo apt-get update
- sudo apt-get install nodejs