本文共 3377 字,大约阅读时间需要 11 分钟。
$ gem sources --add https://ruby.taobao.org/ --remove https://rubygems.org/$ gem sources -l*** CURRENT SOURCES ***https://ruby.taobao.org# 请确保只有 ruby.taobao.org这样就可以用gem install xxxx 来安装东西了,具体请查阅相关文档
sudo yum install rubysudo yum install gcc g++ make automake autoconf curl-devel openssl-devel zlib-devel httpd-devel apr-devel apr-util-devel sqlite-develsudo yum install ruby-rdoc ruby-develyum install rubygems
gem install mysql不过在安装前请确保你安装过mysql,如果没有请执行
yum install mysqlyum install mysql-devel否则你无法从gem安装mysql
#!/usr/bin/rubyrequire "rubygems"require 'mysql'begin con = Mysql.new 'localhost', 'root', 'root','test' puts "mysql version: #{con.get_server_info}" rs = con.query 'select * from student;' #get rows n_rows = rs.num_rows puts "There are #{n_rows} rows in the result set" rs.each_hash do |row| puts row['name'] + " " + row['age'] endrescue Mysql::Error => e puts e.errno puts e.errorensure con.close if conend解释
yum update
# yum install gcc-c++ patch readline readline-devel zlib zlib-devel # yum install libyaml-devel libffi-devel openssl-devel make # yum install bzip2 autoconf automake libtool bison iconv-devel
# curl -L get.rvm.io | bash -s stable你会看到类似的输出结果
% Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed100 20511 100 20511 0 0 1120 0 0:00:18 0:00:18 --:--:-- 19722Downloading https://github.com/wayneeseguin/rvm/archive/stable.tar.gzCreating group 'rvm'Installing RVM to /usr/local/rvm/Installation of RVM in /usr/local/rvm/ is almost complete: * First you need to add all users that will be using rvm to 'rvm' group, and logout - login again, anyone using rvm will be operating with `umask u=rwx,g=rwx,o=rx`. * To start using RVM you need to run `source /etc/profile.d/rvm.sh` in all your open shell windows, in rare cases you need to reopen all shell windows.# Administrator,## Thank you for using RVM!# We sincerely hope that RVM helps to make your life easier and more enjoyable!!!## ~Wayne, Michal & team.In case of problems: http://rvm.io/help and https://twitter.com/rvm_io
source /etc/profile.d/rvm.sh
rvm install 1.9.3
rvm gemset create gemset_name # gemset_name 是一个随便的名字rvm ruby_version@gemset_name # 指定ruby 版本和 gemset_name 名字实际例子
rvm gemset create 9gemrvm 1.9.3@9gem至此就升级完毕了,gems也是RVM管理的gems不是yum安装的那个
转载地址:http://qcdrj.baihongyu.com/