ROR安裝

請參考    http://blog.csdn.net/zzsg2005/article/details/7286036

How to install Ruby on Rails in Ubuntu 11.10


------下面是第一次安裝,有問題:如重新啓動後,rails執行不起來---------------------------


下載ruby1.9.3包

   wget http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p0.tar.gz
   tar xzvf ruby-1.9.3-p0.tar.gz
   cd ruby-1.9.3-p0

   ./configure prefix=/usr/local/ruby1930

 sudo make

 sudo make install


設置路徑set path

  sudo gedit /etc/profile

 如果沒有 gedit 可以 用vi編輯器

  vi /etc/profile

  在末尾加上 : export PATH=/usr/local/ruby193p0/bin:$PATH

 說明: vi 的方法 ,光標移到最後 輸入  o  在最後新增 一行。

輸入 export PATH=/usr/local/ruby193p0/bin:$PATH

再按鍵盤的  esc  ,,輸入 :w 保存 文件   :q! 強制退出


安裝rubygems

從rubygems.rubyforge.org上下載rubygems源碼,bash代碼
$tar zxvf rubygems-1.8.17
$cd rubygems-1.8.17
$sudo ruby setup.rb

提示ruby不是命令。解決:建立連接:

$sudo ln -s /usr/bin/ruby1.9.1 /usr/bin/ruby 

$ ruby -v

   ruby 1.9.2p0 (2010-08-18 revision 29036) [i686-linux]

重新執行安裝命令:
acer@ubntu:~/ruby/rubygems-1.8.17$ sudo ruby setup.rb
   RubyGems 1.8.17 installed

== 1.8.17 / 2012-02-17

* 2 minor enhancements:

  * Add MacRuby to the list of special cases for platforms (ferrous26)
  * Add a default for where to install rubygems itself

* 3 bug fixes:

  * Fixed gem loading issue caused by dependencies not resolving.
  * Fixed umask error when stdlib is required and unresolved dependencies exist.
  * Shebang munging would only take one arg after the cmd
  * Define SUCKAGE better, ie only MRI 1.9.2
  * Propagate env-shebang to the pristine command if set for install.

------------------------------------------------------------------------------

RubyGems installed the following executables:
    /usr/bin/gem1.9.1


acer@ubuntu:~/ruby$ gem -v
程序 'gem' 已包含在下列軟件包中:
 * rubygems1.8
 * rubygems1.9.1
請嘗試:sudo apt-get install <選定的軟件包>

查看/usr/bin/下有gem1.9.1


acer@ubuntu:~/ruby$ dpkg -l rubygems1.8
期望狀態=未知(u)/安裝(i)/刪除(r)/清除(p)/保持(h)
| 狀態=未安裝(n)/已安裝(i)/僅存配置(c)/僅解壓縮(U)/配置失敗(F)/不完全安裝(H)/觸發器等待(W)/觸發器未決(T)
|/ 錯誤?=(無)/須重裝(R) (狀態,錯誤:大寫=故障)
||/ 名稱         版本         簡介
+++-==============-==============-============================================
rc  rubygems1.8    1.3.7-2        package management framework for Ruby librar
acer@ubuntu:~/ruby$ sudo apt-get remove rubygems1.8
[sudo] password for acer:
正在讀取軟件包列表... 完成
正在分析軟件包的依賴關係樹       
正在讀取狀態信息... 完成       
軟件包 rubygems1.8 還未安裝,因而不會被卸載
升級了 0 個軟件包,新安裝了 0 個軟件包,要卸載 0 個軟件包,有 11 個軟件包未被升級。
acer@ubuntu:~/ruby$ dpkg -l rubygems1.9.1
期望狀態=未知(u)/安裝(i)/刪除(r)/清除(p)/保持(h)
| 狀態=未安裝(n)/已安裝(i)/僅存配置(c)/僅解壓縮(U)/配置失敗(F)/不完全安裝(H)/觸發器等待(W)/觸發器未決(T)
|/ 錯誤?=(無)/須重裝(R) (狀態,錯誤:大寫=故障)
||/ 名稱            版本            簡介
+++-=================-=================-==================================================
un  rubygems1.9.1     <無>             (無可用描述)

acer@ubuntu:~/ruby$ sudo ln -s /usr/bin/gem1.9.1 /usr/bin/gem

acer@ubuntu:~/ruby$ gem -v
1.8.17

acer@ubuntu:~/ruby$ sudo gem install rails
Fetching: i18n-0.6.0.gem (100%)
Fetching: multi_json-1.1.0.gem (100%)
Fetching: activesupport-3.2.1.gem (100%)
Fetching: builder-3.0.0.gem (100%)
Fetching: activemodel-3.2.1.gem (100%)
Fetching: rack-1.4.1.gem (100%)
Fetching: rack-cache-1.1.gem (100%)
Fetching: rack-test-0.6.1.gem (100%)
Fetching: journey-1.0.1.gem (100%)
Fetching: hike-1.2.1.gem (100%)
Fetching: tilt-1.3.3.gem (100%)
Fetching: sprockets-2.1.2.gem (100%)
Fetching: erubis-2.7.0.gem (100%)
Fetching: actionpack-3.2.1.gem (100%)
Fetching: arel-3.0.0.gem (100%)
Fetching: tzinfo-0.3.31.gem (100%)
Fetching: activerecord-3.2.1.gem (100%)
Fetching: activeresource-3.2.1.gem (100%)
Fetching: mime-types-1.17.2.gem (100%)
Fetching: polyglot-0.3.3.gem (100%)
Fetching: treetop-1.4.10.gem (100%)
Fetching: mail-2.4.1.gem (100%)
Fetching: actionmailer-3.2.1.gem (100%)
Fetching: rake-0.9.2.2.gem (100%)
Fetching: thor-0.14.6.gem (100%)
Fetching: rack-ssl-1.3.2.gem (100%)
Fetching: json-1.6.5.gem (100%)
Building native extensions.  This could take a while...
Fetching: rdoc-3.12.gem (100%)
Depending on your version of ruby, you may need to install ruby rdoc/ri data:

<= 1.8.6 : unsupported
 = 1.8.7 : gem install rdoc-data; rdoc-data --install
 = 1.9.1 : gem install rdoc-data; rdoc-data --install
>= 1.9.2 : nothing to do! Yay!
Fetching: railties-3.2.1.gem (100%)
Fetching: bundler-1.0.22.gem (100%)
Fetching: rails-3.2.1.gem (100%)
Successfully installed i18n-0.6.0

acer@ubuntu:~/ruby$ rails -v
Rails 3.2.1

安裝mysql
sudo apt-get install mysql-server

將會安裝下列額外的軟件包:
  libdbd-mysql-perl libdbi-perl libhtml-template-perl libnet-daemon-perl libplrpc-perl
  mysql-client-5.1 mysql-server-5.1
建議安裝的軟件包:
  libipc-sharedcache-perl tinyca mailx
下列【新】軟件包將被安裝:
  libdbd-mysql-perl libdbi-perl libhtml-template-perl libnet-daemon-perl libplrpc-perl
  mysql-client-5.1 mysql-server mysql-server-5.1
升級了 0 個軟件包,新安裝了 8 個軟件包,要卸載 0 個軟件包,有 11 個軟件包未被升級。
需要下載 16.2MB 的軟件包。
解壓縮後會消耗掉 37.9MB 的額外空間。
您希望繼續執行嗎?[Y/n]y

acer@ubuntu:~/ruby$ sudo apt-get install libipc-sharedcache-perl tinyca mailx
軟件包 mailx 是一個由下面的軟件包提供的虛擬軟件包:
  mailutils 1:2.1+dfsg1-6
  heirloom-mailx 12.4-2
  bsd-mailx 8.1.2-0.20100314cvs-1
請您明確地選擇一個來進行安裝。


E: 軟件包 mailx 沒有可供安裝的候選者
acer@ubuntu:~/ruby$ sudo apt-get install libipc-sharedcache-perl tinyca mailutils
正在讀取軟件包列表... 完成
正在分析軟件包的依賴關係樹       
正在讀取狀態信息... 完成       
將會安裝下列額外的軟件包:
  libgsasl7 libipc-sharelite-perl libmailutils2 libntlm0 postfix
建議安裝的軟件包:
  mailutils-mh procmail postfix-mysql postfix-pgsql postfix-ldap postfix-pcre sasl2-bin
  resolvconf postfix-cdb
下列【新】軟件包將被安裝:
  libgsasl7 libipc-sharedcache-perl libipc-sharelite-perl libmailutils2 libntlm0 mailutils
  postfix tinyca
升級了 0 個軟件包,新安裝了 8 個軟件包,要卸載 0 個軟件包,有 11 個軟件包未被升級。
需要下載 3,129kB 的軟件包。
解壓縮後會消耗掉 8,888kB 的額外空間。
您希望繼續執行嗎?[Y/n]y

獲取:1 http://cn.archive.ubuntu.com/ubuntu/ maverick/universe libntlm0 i386 1.1-1 [18.1kB]
獲取:2 http://security.ubuntu.com/ubuntu/ maverick-security/main postfix i386 2.7.1-1ubuntu0.2 [1,306kB]
獲取:3 http://cn.archive.ubuntu.com/ubuntu/ maverick/universe libgsasl7 i386 1.4.4-1ubuntu1 [188kB]
獲取:4 http://cn.archive.ubuntu.com/ubuntu/ maverick/main libipc-sharelite-perl i386 0.17-1+build2 [28.7kB]
獲取:5 http://cn.archive.ubuntu.com/ubuntu/ maverick/main libipc-sharedcache-perl all 1.3-8 [25.3kB]
獲取:6 http://cn.archive.ubuntu.com/ubuntu/ maverick/universe libmailutils2 i386 1:2.1+dfsg1-6 [1,043kB]
獲取:7 http://cn.archive.ubuntu.com/ubuntu/ maverick/universe mailutils i386 1:2.1+dfsg1-6 [391kB]
獲取:8 http://cn.archive.ubuntu.com/ubuntu/ maverick/universe tinyca all 0.7.5-2 [130kB]   
下載 3,129kB,耗時 5分 0秒 (10.4kB/s)                                                       
正在預設定軟件包 ...
選中了曾被取消選擇的軟件包 libntlm0。
(正在讀取數據庫 ... 系統當前共安裝有 208870 個文件和目錄。)
正在解壓縮 libntlm0 (從 .../libntlm0_1.1-1_i386.deb) ...
選中了曾被取消選擇的軟件包 libgsasl7。
正在解壓縮 libgsasl7 (從 .../libgsasl7_1.4.4-1ubuntu1_i386.deb) ...
選中了曾被取消選擇的軟件包 libipc-sharelite-perl。
正在解壓縮 libipc-sharelite-perl (從 .../libipc-sharelite-perl_0.17-1+build2_i386.deb) ...
選中了曾被取消選擇的軟件包 libipc-sharedcache-perl。
正在解壓縮 libipc-sharedcache-perl (從 .../libipc-sharedcache-perl_1.3-8_all.deb) ...
選中了曾被取消選擇的軟件包 libmailutils2。
正在解壓縮 libmailutils2 (從 .../libmailutils2_1%3a2.1+dfsg1-6_i386.deb) ...
選中了曾被取消選擇的軟件包 postfix。
正在解壓縮 postfix (從 .../postfix_2.7.1-1ubuntu0.2_i386.deb) ...
選中了曾被取消選擇的軟件包 mailutils。
正在解壓縮 mailutils (從 .../mailutils_1%3a2.1+dfsg1-6_i386.deb) ...
選中了曾被取消選擇的軟件包 tinyca。
正在解壓縮 tinyca (從 .../tinyca_0.7.5-2_all.deb) ...
正在處理用於 man-db 的觸發器...
正在處理用於 ureadahead 的觸發器...
正在處理用於 ufw 的觸發器...
正在設置 libntlm0 (1.1-1) ...
正在設置 libgsasl7 (1.4.4-1ubuntu1) ...
正在設置 libipc-sharelite-perl (0.17-1+build2) ...
正在設置 libipc-sharedcache-perl (1.3-8) ...
正在設置 libmailutils2 (1:2.1+dfsg1-6) ...
正在設置 postfix (2.7.1-1ubuntu0.2) ...
正在添加組"postfix" (GID 126)...
完成。
正在添加系統用戶"postfix" (UID 117)...
正在將新用戶"postfix" (UID 117)添加到組"postfix"...
無法創建主目錄"/var/spool/postfix"
Creating /etc/postfix/dynamicmaps.cf
Adding tcp map entry to /etc/postfix/dynamicmaps.cf
正在添加組"postdrop" (GID 127)...
完成。
/etc/aliases does not exist, creating it.

Postfix was not set up.  Start with
  cp /usr/share/postfix/main.cf.debian /etc/postfix/main.cf
.  If you need to make changes, edit
/etc/postfix/main.cf (and others) as needed.  To view Postfix configuration
values, see postconf(1).

After modifying main.cf, be sure to run '/etc/init.d/postfix reload'.

正在設置 mailutils (1:2.1+dfsg1-6) ...
update-alternatives: 使用 /usr/bin/frm.mailutils 來提供 /usr/bin/frm (frm),於 自動模式 中。
update-alternatives: 使用 /usr/bin/from.mailutils 來提供 /usr/bin/from (from),於 自動模式 中。
update-alternatives: 使用 /usr/bin/messages.mailutils 來提供 /usr/bin/messages (messages),於 自動模式 中。
update-alternatives: 使用 /usr/bin/movemail.mailutils 來提供 /usr/bin/movemail (movemail),於 自動模式 中。
update-alternatives: 使用 /usr/bin/readmsg.mailutils 來提供 /usr/bin/readmsg (readmsg),於 自動模式 中。
update-alternatives: 使用 /usr/bin/dotlock.mailutils 來提供 /usr/bin/dotlock (dotlock),於 自動模式 中。
update-alternatives: 使用 /usr/bin/mail.mailutils 來提供 /usr/bin/mailx (mailx),於 自動模式 中。
正在設置 tinyca (0.7.5-2) ...
正在處理用於 libc-bin 的觸發器...
ldconfig deferred processing now taking place


acer@ubuntu:~/ruby$ rails new demo
      create  
      create  README.rdoc
      create  Rakefile
      create  config.ru
      create  .gitignore
      create  Gemfile
      create  app
      create  app/assets/images/rails.png
      create  app/assets/javascripts/application.js
      create  app/assets/stylesheets/application.css
      create  app/controllers/application_controller.rb
      create  app/helpers/application_helper.rb
      create  app/mailers
      create  app/models
      create  app/views/layouts/application.html.erb
      create  app/mailers/.gitkeep
      create  app/models/.gitkeep
      create  config
      create  config/routes.rb
      create  config/application.rb
      create  config/environment.rb
      create  config/environments
      create  config/environments/development.rb
      create  config/environments/production.rb
      create  config/environments/test.rb
      create  config/initializers
      create  config/initializers/backtrace_silencers.rb
      create  config/initializers/inflections.rb
      create  config/initializers/mime_types.rb
      create  config/initializers/secret_token.rb
      create  config/initializers/session_store.rb
      create  config/initializers/wrap_parameters.rb
      create  config/locales
      create  config/locales/en.yml
      create  config/boot.rb
      create  config/database.yml
      create  db
      create  db/seeds.rb
      create  doc
      create  doc/README_FOR_APP
      create  lib
      create  lib/tasks
      create  lib/tasks/.gitkeep
      create  lib/assets
      create  lib/assets/.gitkeep
      create  log
      create  log/.gitkeep
      create  public
      create  public/404.html
      create  public/422.html
      create  public/500.html
      create  public/favicon.ico
      create  public/index.html
      create  public/robots.txt
      create  script
      create  script/rails
      create  test/fixtures
      create  test/fixtures/.gitkeep
      create  test/functional
      create  test/functional/.gitkeep
      create  test/integration
      create  test/integration/.gitkeep
      create  test/unit
      create  test/unit/.gitkeep
      create  test/performance/browsing_test.rb
      create  test/test_helper.rb
      create  tmp/cache
      create  tmp/cache/assets
      create  vendor/assets/javascripts
      create  vendor/assets/javascripts/.gitkeep
      create  vendor/assets/stylesheets
      create  vendor/assets/stylesheets/.gitkeep
      create  vendor/plugins
      create  vendor/plugins/.gitkeep
         run  bundle install


Fetching source index for https://rubygems.org/
Using rake (0.9.2.2)
Using i18n (0.6.0)
Using multi_json (1.1.0)
Using activesupport (3.2.1)
Using builder (3.0.0)
Using activemodel (3.2.1)
Using erubis (2.7.0)
Using journey (1.0.1)
Using rack (1.4.1)
Using rack-cache (1.1)
Using rack-test (0.6.1)
Using hike (1.2.1)
Using tilt (1.3.3)
Using sprockets (2.1.2)
Using actionpack (3.2.1)
Using mime-types (1.17.2)
Using polyglot (0.3.3)
Using treetop (1.4.10)
Using mail (2.4.1)
Using actionmailer (3.2.1)

Using arel (3.0.0)
Using tzinfo (0.3.31)
Using activerecord (3.2.1)
Using activeresource (3.2.1)
Using bundler (1.0.22)
Installing coffee-script-source (1.2.0)
Installing execjs (1.3.0)
Installing coffee-script (2.2.0)
Using rack-ssl (1.3.2)
Using json (1.6.5)
Using rdoc (3.12)
Using thor (0.14.6)
Using railties (3.2.1)
Installing coffee-rails (3.2.2)
Installing jquery-rails (2.0.0)
Using rails (3.2.1)
Installing sass (3.1.15)
Installing sass-rails (3.2.4)

Installing sqlite3 (1.3.5) with native extensions
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

        /usr/bin/ruby1.9.1 extconf.rb
checking for sqlite3.h... no
sqlite3.h is missing. Try 'port install sqlite3 +universal'
or 'yum install sqlite-devel' and check your shared library search path (the
location where your sqlite3 shared library is located).

*** 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:
    --with-opt-dir
    --without-opt-dir
    --with-opt-include
    --without-opt-include=${opt-dir}/include
    --with-opt-lib
    --without-opt-lib=${opt-dir}/lib
    --with-make-prog
    --without-make-prog
    --srcdir=.
    --curdir
    --ruby=/usr/bin/ruby1.9.1
    --with-sqlite3-dir
    --without-sqlite3-dir
    --with-sqlite3-include
    --without-sqlite3-include=${sqlite3-dir}/include
    --with-sqlite3-lib
    --without-sqlite3-lib=${sqlite3-dir}/lib
    --enable-local
    --disable-local


Gem files will remain installed in /home/acer/.bundler/tmp/20720/gems/sqlite3-1.3.5 for inspection.
Results logged to /home/acer/.bundler/tmp/20720/gems/sqlite3-1.3.5/ext/sqlite3/gem_make.out
An error occured while installing sqlite3 (1.3.5), and Bundler cannot continue.
Make sure that `gem install sqlite3 -v '1.3.5'` succeeds before bundling.

哦,系統中沒有安裝sqlite3.[和mysql一樣,要在rails項目構建前先安裝環境]

acer@ubuntu:~$ sudo apt-get install libsqlite3-dev

正在設置 libsqlite3-dev (3.7.2-1) ...
acer@ubuntu:~$ sudo ruby /usr/lib/ruby/gems/1.9.1/gems/sqlite3-1.3.5/setup.rb

acer@ubuntu:~$ rails new demo

    。。。

   Installing sqlite3 (1.3.5) with native extensions
   Installing uglifier (1.2.3)

  Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.
acer@ubuntu:~$ sudo apt-get install imagemagick

    ...正在設置 imagemagick (7:6.6.2.6-1ubuntu1.1) ...
    正在設置 libcdt4 (2.26.3-4) ...
    正在設置 libgraph4 (2.26.3-4) ...
    正在設置 libpathplan4 (2.26.3-4) ...
    正在設置 libxdot4 (2.26.3-4) ...
    正在設置 libgvc5 (2.26.3-4) ...
    正在設置 libmagickcore3-extra (7:6.6.2.6-1ubuntu1.1) ...


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章