Centos上安装ruby,rbenv
利用rbenv 在centos上安装ruby
🕐
安装必备的包
yum install -y git-core zlib zlib-devel gcc-c++ patch readline readline-devel libyaml-devel libffi-devel openssl-devel make bzip2 autoconf automake libtool bison curl sqlite-develcd
git clone https://github.com/rbenv/rbenv.git ~/.rbenv
# 用来编译安装 ruby
git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
# 用来管理 gemset, 可选, 因为有 bundler 也没什么必要
git clone https://github.com/jamis/rbenv-gemset.git ~/.rbenv/plugins/rbenv-gemset
# 通过 rbenv update 命令来更新 rbenv 以及所有插件, 推荐
git clone https://github.com/rkh/rbenv-update.git ~/.rbenv/plugins/rbenv-update
# 使用 Ruby China 的镜像安装 Ruby, 国内用户推荐
git clone https://github.com/AndorChen/rbenv-china-mirror.git ~/.rbenv/plugins/rbenv-china-mirror添加到 .bashrc
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
export RUBY_BUILD_MIRROR_URL=https://cache.ruby-china.com从 cache中安装
## prepare package
mkdir -p ~/.rbenv/cache
cd ~/.rbenv/cache
wget https://cache.ruby-china.com/pub/ruby/2.6/ruby-2.6.5.tar.bz2rbenv常用命令
| 功能 | 描述 |
|---|---|
| 列出所有可用版本 | |
| 安装某个版本 | |
| rehash | |
| 使刚安装的版本生效 | |
安装报错
openssl_missing.h:75:0: warning: "X509_STORE_get_ex_new_index" redefined 
openssl 相关
# 获得dir相关信息
openssl version -d
# 版本
openssl version可能的修复方案
export RUBY_CONFIGURE_OPTS="--with-openssl-dir=/usr/local/openssl"
rbenv install 2.6.5[root@ecs-eqyaP openssl]# export RUBY_CONFIGURE_OPTS="--with-openssl-dir=/usr/local/openssl"
[root@ecs-eqyaP openssl]# rbenv install 2.6.5
Installing ruby-2.6.5...
Installed ruby-2.6.5 to /root/.rbenv/versions/2.6.5安装gem报错
ERROR: SSL verification error at depth 1: unable to get local issuer certificate (20)
ERROR: You must add /OU=GlobalSign Root CA - R3/O=GlobalSign/CN=GlobalSign to your local trusted store
ERROR: SSL verification error at depth 1: unable to get local issuer certificate (20)
ERROR: You must add /OU=GlobalSign Root CA - R3/O=GlobalSign/CN=GlobalSign to your local trusted store
ERROR: SSL verification error at depth 1: unable to get local issuer certificate (20)
ERROR: You must add /OU=GlobalSign Root CA - R3/O=GlobalSign/CN=GlobalSign to your local trusted store
ERROR: Could not find a valid gem 'whenever' (>= 0), here is why:
Unable to download data from https://rubygems.org/ - SSL_connect returned=1 errno=0 state=error: certificate verify failed (unable to get local issuer certificate) (https://rubygems.org/specs.4.8.gz)
ERROR: SSL verification error at depth 1: unable to get local issuer certificate (20)
ERROR: You must add /OU=GlobalSign Root CA - R3/O=GlobalSign/CN=GlobalSign to your local trusted store
ERROR: SSL verification error at depth 1: unable to get local issuer certificate (20)
ERROR: You must add /OU=GlobalSign Root CA - R3/O=GlobalSign/CN=GlobalSign to your local trusted store# 到这里 https://rubygems.org/pages/download 下载最新的版本即可
cd /tmp
wget https://rubygems.org/rubygems/rubygems-3.3.10.tgz
tar zxf rubygems-3.3.10.tgz
cd rubygems-3.3.10
ruby setup.rb参考
- https://ruby-china.org/wiki/rbenv-guide
- https://www.digitalocean.com/community/tutorials/how-to-install-ruby-on-rails-with-rbenv-on-centos-7
- https://codingpackets.com/blog/rbenv-install-centos-7/
- https://stackoverflow.com/questions/64029645/rbenv-ruby-build-installs-fail-for-ruby-versions-1-9-3-2-2-0-2-2-5-with-xcod
- https://stackoverflow.com/questions/24959340/which-directory-is-the-openssldir
- https://qiita.com/kazutosato/items/9c4ff7711ca992dd67e5
- https://github.com/rubygems/rubygems/issues/1758
- https://bundler.io/v2.0/guides/rubygems_tls_ssl_troubleshooting_guide.html#troubleshooting-certificate-errors
- https://rubygems.org/pages/download