温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

CentOS安装Ruby,Rails运行环境

发布时间:2020-07-27 09:22:21 来源:网络 阅读:3420 作者:郝路路 栏目:编程语言
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 stable
RVM改用淘宝下载源,提高ruby等软件安装速度
# sed -i 's!ftp.ruby-lang.org/pub/ruby!ruby.taobao.org/mirrors/ruby!' $rvm_path/config/db
Ruby安装:
首先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 found
Error 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 -v
RubyGem默认源安装慢,可以修改成淘宝的源提升速度
移除原安装源
# gem sources --remove https://rubygems.org/
添加淘宝源
# gem sources -a http://ruby.taobao.org/
查看源的地址
# 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.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.
这是由于sqlite-devel没有安装,安装即可
安装rails
# gem install rails --no-ri --no-rdoc
查看rails版本
# rails -v
為了節省安裝時間可不安裝文件檔,這裡加上--no-ri跟--no-rdoc參數。
至此rails开发环境已结束!


向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI