在Ubuntu上安裝rails上的安裝環境很多次,每次都碰到很多問題,這次把在Ubuntu 12.04上安裝的步驟記錄下來,省得以後再安裝麻煩
1.首先安裝g++ ubuntu上一般沒有裝這個,這個裝上去為了編譯安裝的軟件
apt-get install g++
2.安裝rvm
bash < <(curl -s https://rvm.beginrescueend.com/install/rvm)
然後配置用戶的根目錄下的這個文件.bashrc
在最後加一句
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"
用下面的命令讓配置起作用
source .bashrc
3.安裝RUBY
https://rvm.io/rvm/install/
這裡有命令可以安裝
4.安裝rails
這個時候如果直接用gem intsll rails可能就會出錯 報
ERROR: Loading command: install (LoadError)
cannot load such file -- zlib
ERROR: While executing gem ... (NameError)
uninitialized constant Gem::Commands::InstallCommand
這個時候應該先下載安裝zlib1g-dev
sudo apt-get install zlib1g-dev
然後再在ruby的源代碼裡面重新編譯zlib
以我的安裝目錄為例,進入如下的路徑 根據安裝的ruyb的版本不同調整路徑
~/.rvm/src/ruby-1.9.3-p194/ext/zlib
運行命令
#ruby ./extconf.rb
#make
#make install
之後再用gem安裝rails就可以了
ok rails的開發環境安裝完成。