使用rvm方式在centos7.5上安装ruby
依次执行:
gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
curl -sSL https://get.rvm.io | bash -s stable #如果下载不下来https://get.rvm.io,可先访问复制脚本到rvm.sh,再cat rvm.sh|bash -s stable
source /etc/profile.d/rvm.sh
rvm list known #查看版本
rvm install 2.4.9 #安装ruby
ruby -v
gem install sass #安装sass
gem install compass #安装compass
sass -v
compass -v
之前尝试用其他方式安装ruby,但是 gem install sass 安装报错,如下。
yum -y install ruby ruby-devel rubygems rpm-build
ruby -v
ruby 2.0.0 版本过低安装不上sass
升级:
yum install -y centos-release-scl-rh
yum install -y rh-ruby23
scl enable rh-ruby23 bash
[root@localhost ~]# ruby -v
ruby 2.3.5p335
此时安装 sass会报错
[root@one huan_yang]# gem install sass
Fetching: ffi-1.12.2.gem (100%)
Building native extensions. This could take a while...
ERROR: Error installing sass:
ERROR: Failed to build gem native extension.
current directory: /opt/rh/rh-ruby23/root/usr/local/share/gems/gems/ffi-1.12.2/ext/ffi_c
/opt/rh/rh-ruby23/root/usr/bin/ruby -r ./siteconf20200522-16492-1d4yj7r.rb extconf.rb
mkmf.rb can't find header files for ruby at /opt/rh/rh-ruby23/root/usr/share/include/ruby.h