CentOS安装Ruby,Rails运行环境

CentOS安装Ruby,Rails运行环境

RVM是一个命令行工具,可以提供一个便捷的多版本ruby环境的管理和切换官方网站:https://rvm.io/RVM安装:# \curl -sSL https://get.rvm.io | bash -s stable第一次运行,会出现error,原因是由于证书问题导致,使用-k命令跳过!# \curl -sSL https://get.rvm.io -k | bash -s stable执行上述命令后,发现无法下载软件包,执行以下操作:# echo insecure >> ~/.curlrc完成上述操作,就可以安装rvm了!# \curl -sSL https://get.rvm.io | bash -s stableRVM改用淘宝下载源,,提高ruby等软件安装速度# sed -i ‘s!ftp.ruby-lang.org/pub/ruby!ruby.taobao.org/mirrors/ruby!’ $rvm_path/config/dbRuby安装:首先ruby会有必要的套件需要安装,通过yum安装套件yum install build-essential bison openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev列出已知的ruby版本# rvm list known安装其中的版本# rvm install 2.0.0出现下列错误Error running ‘requirements_centos_update_system ruby-2.0.0-p353’,showing last 15 lines of /usr/local/rvm/log/1392712886_ruby-2.0.0-p353/update_system.log }-bash: yum-config-manager: command not foundError installing EPEL, it is required for libyaml-devel,either there was an error installing EPEL package,or there was problem checking if libyaml-devel is available / installed.Requirements installation failed with status: 127.

原因是由于libyaml-devel没有安装,通过yum安装即可# yum install libyaml-devel再次运行rvm安装ruby查看ruby版本# ruby -v查看gem版本(安装ruby会自动安装gem)# gem -vRubyGem默认源安装慢,可以修改成淘宝的源提升速度移除原安装源# gem sources –remove https://rubygems.org/添加淘宝源# gem sources -a 查看源的地址# gem sources -l安装Ruby on Rails首先安装SQLite # gem install sqlite3 –no-ri –no-rdoc出现错误,错误信息Fetching: sqlite3-1.3.8.gem (100%)Building native extensions. This could take a while…ERROR: Error installing sqlite3: ERROR: Failed to build gem native extension.

/usr/local/rvm/rubies/ruby-2.0.0-p353/bin/ruby extconf.rbchecking for sqlite3.h… nosqlite3.h is missing. Try ‘port install sqlite3 +universal’or ‘yum install sqlite-devel’ and check your shared library search path (thelocation where your sqlite3 shared library is located).*** extconf.rb failed ***Could not create Makefile due to some reason, probably lack of necessarylibraries and/or headers. Check the mkmf.log file for more details. You mayneed configuration options.

这是由于sqlite-devel没有安装,安装即可安装rails# gem install rails –no-ri –no-rdoc查看rails版本# rails -v為了節省安裝時間可不安裝文件檔,這裡加上–no-ri跟–no-rdoc參數。至此rails开发环境已结束!

相关阅读:

Ubuntu 13.04下Ruby的安装

用最少的浪费面对现在

CentOS安装Ruby,Rails运行环境

相关文章:

你感兴趣的文章:

标签云: