Ruby on Rails的安裝

環(huán)境:VMware上的Ubuntu系統(tǒng)

不知道是否使用因?yàn)閂Mware的問題纲辽,這次安裝Ruby和Rails時(shí)遇到了非常多問題递惋。在網(wǎng)上查詢時(shí)坑匠,也遇到了很多沒有提供解決方法的博主砚哆。因?yàn)楝F(xiàn)在我找到了解決方法惊来,就在這總結(jié)一下我所遇到的問題吧。
首先桐腌,我終于看到這個(gè)頁面啦V粝浴!案站!


Ruby on Rails

一般的安裝過程

  1. 使用apt-get安裝最新版本的ruby
sudo apt-get update 
sudo apt-get install ruby2.3
  • 使用apt-get安裝ruby的依賴包
sudo apt-get install ruby2.3-dev
  • 使用gem安裝Rails
sudo gem install rails
  • 安裝Rails的依賴包
sudo apt-get install libsqlite3-dev 
sudo gem install sqlite3 
bundle install
sudo apt install ruby-railties
  • 在Rails中創(chuàng)建新的工程躬审,并進(jìn)入創(chuàng)建的工程。
rails new [project_name]
cd [project_name]
  • 啟動(dòng)server蟆盐,測試Rails是否安裝成功承边。在瀏覽器中訪問http://localhost:3000
rails server

不一般的安裝過程(問題)

install rails中可能遇到的問題
  1. Error: Can not find 'bundle'
    'bundle' is currently not installed.
    Solutions:
sudo apt install ruby-bundler
  • Error: Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

Installing nokogiri 1.6.8.1 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory: /tmp/bundler20161216-4008-jpesjqnokogiri-1.6.8.1/gems/nokogiri-1.6.8.1/ext/nokogiri
/usr/bin/ruby2.3 -r ./siteconf20161216-4008-1uempjz.rb extconf.rb
checking if the C compiler accepts ... yes
Building nokogiri using packaged libraries.
Using mini_portile version 2.1.0
checking for gzdopen() in -lz... no
zlib is missing; necessary for building libxml2
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers. Check the mkmf.log file for more details. You may
need configuration options.
Provided configuration options:
...
To see why this extension failed to compile, please check the mkmf.log which can be found here:
/tmp/bundler20161216-4008-jpesjqnokogiri-1.6.8.1/extensions/x86_64-linux/2.3.0/nokogiri-1.6.8.1/mkmf.log
extconf failed, exit code 1

Gem files will remain installed in /tmp/bundler20161216-4008-jpesjqnokogiri-1.6.8.1/gems/nokogiri-1.6.8.1 for inspection.
Results logged to /tmp/bundler20161216-4008-jpesjqnokogiri-1.6.8.1/extensions/x86_64-linux/2.3.0/nokogiri-1.6.8.1/gem_make.out
An error occurred while installing nokogiri (1.6.8.1), and Bundler cannot continue.

Solutions:

sudo gem install nokogiri
  • Error: ERROR: Error installing nokogiri:

$ sudo gem install nokogiri
Building native extensions. This could take a while...
ERROR: Error installing nokogiri:
ERROR: Failed to build gem native extension.
current directory: /var/lib/gems/2.3.0/gems/nokogiri-1.6.8.1/ext/nokogiri
/usr/bin/ruby2.3 -r ./siteconf20161216-4223-jip6ko.rb extconf.rb
checking if the C compiler accepts ... yes
Building nokogiri using packaged libraries.
Using mini_portile version 2.1.0
checking for gzdopen() in -lz... no
zlib is missing; necessary for building libxml2
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers. Check the mkmf.log file for more details. You may
need configuration options.
Provided configuration options:
...
To see why this extension failed to compile, please check the mkmf.log which can be found here:
/var/lib/gems/2.3.0/extensions/x86_64-linux/2.3.0/nokogiri-1.6.8.1/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in /var/lib/gems/2.3.0/gems/nokogiri-1.6.8.1 for inspection.
Results logged to /var/lib/gems/2.3.0/extensions/x86_64-linux/2.3.0/nokogiri-1.6.8.1/gem_make.out

Solutions:

sudo apt-get install libxslt-dev libxml2-dev
sudo apt-get install build-essential patch
sudo apt-get install zlib1g-dev liblzma-dev
  • Error:
Bundler::GemRequireError`
There was an error while trying to load the gem 'uglifier'

$ rails server
/usr/lib/ruby/vendor_ruby/bundler/runtime.rb:80:in rescue in block (2 levels) in require': There was an error while trying to load the gem 'uglifier'. (Bundler::GemRequireError) from /usr/lib/ruby/vendor_ruby/bundler/runtime.rb:76:inblock (2 levels) in require'
from /usr/lib/ruby/vendor_ruby/bundler/runtime.rb:72:in each' from /usr/lib/ruby/vendor_ruby/bundler/runtime.rb:72:inblock in require'
from /usr/lib/ruby/vendor_ruby/bundler/runtime.rb:61:in each' from /usr/lib/ruby/vendor_ruby/bundler/runtime.rb:61:inrequire'
from /usr/lib/ruby/vendor_ruby/bundler.rb:99:in require' from /home/zhen/blog/config/application.rb:7:in<top (required)>'
from /usr/lib/ruby/vendor_ruby/rails/commands/commands_tasks.rb:78:in require' from /usr/lib/ruby/vendor_ruby/rails/commands/commands_tasks.rb:78:inblock in server'
from /usr/lib/ruby/vendor_ruby/rails/commands/commands_tasks.rb:75:in tap' from /usr/lib/ruby/vendor_ruby/rails/commands/commands_tasks.rb:75:inserver'
from /usr/lib/ruby/vendor_ruby/rails/commands/commands_tasks.rb:39:in run_command!' from /usr/lib/ruby/vendor_ruby/rails/commands.rb:17:in<top (required)>'
from bin/rails:4:in require' from bin/rails:4:in<main>'

Solutions:

sudo apt-get install nodejs
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末舱禽,一起剝皮案震驚了整個(gè)濱河市炒刁,隨后出現(xiàn)的幾起案子恩沽,更是在濱河造成了極大的恐慌誊稚,老刑警劉巖,帶你破解...
    沈念sama閱讀 216,324評(píng)論 6 498
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場離奇詭異里伯,居然都是意外死亡城瞎,警方通過查閱死者的電腦和手機(jī),發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 92,356評(píng)論 3 392
  • 文/潘曉璐 我一進(jìn)店門疾瓮,熙熙樓的掌柜王于貴愁眉苦臉地迎上來脖镀,“玉大人,你說我怎么就攤上這事狼电⊙鸦遥” “怎么了?”我有些...
    開封第一講書人閱讀 162,328評(píng)論 0 353
  • 文/不壞的土叔 我叫張陵肩碟,是天一觀的道長强窖。 經(jīng)常有香客問我,道長削祈,這世上最難降的妖魔是什么翅溺? 我笑而不...
    開封第一講書人閱讀 58,147評(píng)論 1 292
  • 正文 為了忘掉前任,我火速辦了婚禮髓抑,結(jié)果婚禮上咙崎,老公的妹妹穿的比我還像新娘。我一直安慰自己吨拍,他們只是感情好褪猛,可當(dāng)我...
    茶點(diǎn)故事閱讀 67,160評(píng)論 6 388
  • 文/花漫 我一把揭開白布。 她就那樣靜靜地躺著羹饰,像睡著了一般握爷。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上严里,一...
    開封第一講書人閱讀 51,115評(píng)論 1 296
  • 那天新啼,我揣著相機(jī)與錄音,去河邊找鬼刹碾。 笑死燥撞,一個(gè)胖子當(dāng)著我的面吹牛,可吹牛的內(nèi)容都是我干的迷帜。 我是一名探鬼主播物舒,決...
    沈念sama閱讀 40,025評(píng)論 3 417
  • 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢啊……” “哼戏锹!你這毒婦竟也來了冠胯?” 一聲冷哼從身側(cè)響起,我...
    開封第一講書人閱讀 38,867評(píng)論 0 274
  • 序言:老撾萬榮一對(duì)情侶失蹤锦针,失蹤者是張志新(化名)和其女友劉穎荠察,沒想到半個(gè)月后置蜀,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體,經(jīng)...
    沈念sama閱讀 45,307評(píng)論 1 310
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡悉盆,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 37,528評(píng)論 2 332
  • 正文 我和宋清朗相戀三年盯荤,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片焕盟。...
    茶點(diǎn)故事閱讀 39,688評(píng)論 1 348
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡秋秤,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出脚翘,到底是詐尸還是另有隱情灼卢,我是刑警寧澤,帶...
    沈念sama閱讀 35,409評(píng)論 5 343
  • 正文 年R本政府宣布来农,位于F島的核電站芥玉,受9級(jí)特大地震影響,放射性物質(zhì)發(fā)生泄漏备图。R本人自食惡果不足惜灿巧,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 41,001評(píng)論 3 325
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望揽涮。 院中可真熱鬧抠藕,春花似錦、人聲如沸蒋困。這莊子的主人今日做“春日...
    開封第一講書人閱讀 31,657評(píng)論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽雪标。三九已至零院,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間村刨,已是汗流浹背告抄。 一陣腳步聲響...
    開封第一講書人閱讀 32,811評(píng)論 1 268
  • 我被黑心中介騙來泰國打工, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留嵌牺,地道東北人打洼。 一個(gè)月前我還...
    沈念sama閱讀 47,685評(píng)論 2 368
  • 正文 我出身青樓,卻偏偏與公主長得像逆粹,于是被迫代替她去往敵國和親募疮。 傳聞我的和親對(duì)象是個(gè)殘疾皇子,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 44,573評(píng)論 2 353

推薦閱讀更多精彩內(nèi)容