2019년 3월 6일 수요일

rvm + ruby 설치하기



회사에서 레드마인을 3.0 대 버전에서 4.0 버전으로 마이그레이션 하라는 요청이 있었다.
그래서 레드마인을 위한 rvm + ruby 기본 설치부터 진행해보기로 했다.
OS환경은 CensOS 6.8 이다.
rvm 설치는 공식사이트 https://rvm.io/rvm/install 를 참조하였다.

처음 시작할 때는 root 권한으로 설치보다 rvm과 ruby를 실제로 사용할 사용자 계정을 따로 생성하여 작업을 진행하는게 좋다. 따라서 root 권한보다는 일반 계정으로 설치를 권장한다.
따라서 redmine 이라는 계정을 하나 생성하기로 한다.

useradd redmine
passwd [패스워드]

1. rvm 설치
 rvm 이란 루비 설치 버전 관리 툴이라고 할 수 있다. 최신버전이나 원하는 루비의 버전 설치를 쉽게 도와주는 툴이다.
 centos에서 rvm이 아닌 yum install ruby 으로 루비를 설치 하게 되면 아래와 같이 최신버전이 아닌 1.8 루비가 자동으로 설치된다.
[root@crm ~]# ruby -v
ruby 1.8.7 (2013-06-27 patchlevel 374) [x86_64-linux] 

따라서 루비 최신버전으로 설치를 하고 추후 버전 관리까지 용이하도록 rvm을 설치 한다.


(1) GPG keys 설치
rvm 패키지가 맞는지 검증하기 위해 공식사이트에서 제공하는 GPG keys라는 것을 먼저 설치한다.
[redmine@5a067717ed9e ~]gpg --keyserver hkp://pool.sks-keyservers.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
gpg: directory `/root/.gnupg' created
gpg: new configuration file `/root/.gnupg/gpg.conf' created
gpg: WARNING: options in `/root/.gnupg/gpg.conf' are not yet active during this run
gpg: keyring `/root/.gnupg/secring.gpg' created
gpg: keyring `/root/.gnupg/pubring.gpg' created
gpg: requesting key D39DC0E3 from hkp server pool.sks-keyservers.net
gpg: requesting key 39499BDB from hkp server pool.sks-keyservers.net
gpg: /root/.gnupg/trustdb.gpg: trustdb created
gpg: key D39DC0E3: public key "Michal Papis (RVM signing) <mpapis@gmail.com>" imported
gpg: key D39DC0E3: public key "Totally Legit Signing Key <mallory@example.org>" imported
gpg: key 39499BDB: public key "Piotr Kuczynski <piotr.kuczynski@gmail.com>" imported
gpg: no ultimately trusted keys found
gpg: Total number processed: 3
gpg:               imported: 3  (RSA: 3)

(2) RVM 안정화 버전 설치
[redmine@5a067717ed9e redmine-4.0.2]$ curl -sSL https://get.rvm.io | bash -s stable --ruby
Downloading https://github.com/rvm/rvm/archive/1.29.7.tar.gz
Downloading https://github.com/rvm/rvm/releases/download/1.29.7/1.29.7.tar.gz.asc
gpg: Signature made Thu 03 Jan 2019 10:01:48 PM UTC using RSA key ID 39499BDB
gpg: Good signature from "Piotr Kuczynski <piotr.kuczynski@gmail.com>"
gpg: WARNING: This key is not certified with a trusted signature!
gpg:          There is no indication that the signature belongs to the owner.
Primary key fingerprint: 7D2B AF1C F37B 13E2 069D  6956 105B D0E7 3949 9BDB
GPG verified '/home/redmine/.rvm/archives/rvm-1.29.7.tgz'
Installing RVM to /home/redmine/.rvm/
    Adding rvm PATH line to /home/redmine/.profile /home/redmine/.mkshrc /home/redmine/.bashrc /home/redmine/.zshrc.
    Adding rvm loading line to /home/redmine/.profile /home/redmine/.bash_profile /home/redmine/.zlogin.
Installation of RVM in /home/redmine/.rvm/ is almost complete:
  * To start using RVM you need to run `source /home/redmine/.rvm/scripts/rvm`
    in all your open shell windows, in rare cases you need to reopen all shell windows.



(3) Rails 설치
curl -sSL https://get.rvm.io | bash -s stable --rails

(4) vi ~/.bashrc
 마지막 라인에 아래를 추가
source /home/redmine/.rvm/scripts/rvm 

(5) 설치 확인
[root@crm ~]# rvm version
rvm 1.29.7 (latest) by Michal Papis, Piotr Kuczynski, Wayne E. Seguin [https://rvm.io]

2. ruby install
(1) rvm으로 ruby 설치하기
rvm install ruby
사용자계정으로 설치 시 sudo 권한이 필요하여 패스워드 입력을 요구한다.
[redmine@5a067717ed9e ~]$ rvm install ruby
Searching for binary rubies, this might take some time.
No binary rubies available for: centos/6/x86_64/ruby-2.6.0.
Continuing with compilation. Please read 'rvm help mount' to get more information on binary rubies.
Checking requirements for centos.
Installing requirements for centos.
Installing required packages: patch, autoconf, automake, bison, gcc-c++, libffi-devel, libtool, patch, readline-devel, sqlite-devel, zlib-devel, glibc-headers, glibc-devel, 
openssl-devel.redmine password required for 'yum install -y patch autoconf automake bison gcc-c++ libffi-devel libtool patch readline-devel sqlite-devel zlib-devel glibc-headers glibc-devel openssl-devel':
.............................
Requirements installation successful.
-bash: /home/redmine/.rvm/scripts/functions/manage/install/centos: No such file or directory
Installing Ruby from source to: /home/redmine/.rvm/rubies/ruby-2.6.0, this may take a while depending on your cpu(s)...
ruby-2.6.0 - #downloading ruby-2.6.0, this may take a while depending on your connection...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 13.9M  100 13.9M    0     0  7399k      0  0:00:01  0:00:01 --:--:-- 8869k
ruby-2.6.0 - #extracting ruby-2.6.0 to /home/redmine/.rvm/src/ruby-2.6.0.....
ruby-2.6.0 - #configuring......................................................................
ruby-2.6.0 - #post-configuration..
ruby-2.6.0 - #compiling...........................................................................................................................
ruby-2.6.0 - #installing...............................
ruby-2.6.0 - #making binaries executable..
Installed rubygems 3.0.1 is newer than 2.7.9 provided with installed ruby, skipping installation, use --force to force installation.
ruby-2.6.0 - #gemset created /home/redmine/.rvm/gems/ruby-2.6.0@global

ruby-2.6.0 - #importing gemset /home/redmine/.rvm/gemsets/global.gems................................................................
ruby-2.6.0 - #generating global wrappers.......

ruby-2.6.0 - #gemset created /home/redmine/.rvm/gems/ruby-2.6.0
ruby-2.6.0 - #importing gemsetfile /home/redmine/.rvm/gemsets/default.gems evaluated to empty gem list
ruby-2.6.0 - #generating default wrappers.......

ruby-2.6.0 - #adjusting #shebangs for (gem irb erb ri rdoc testrb rake).
Install of ruby-2.6.0 - #complete
Ruby was built without documentation, to build it run: rvm docs generate-ri
Error running 'requirements_centos_libs_install patch autoconf automake bison gcc-c++ libffi-devel libtool patch readline-devel sqlite-devel zlib-devel glibc-headers glibc-devel openssl-devel',
please read /home/redmine/.rvm/log/1552008743_ruby-2.6.0/package_install_patch_autoconf_automake_bison_gcc-c++_libffi-devel_libtool_patch_readline-devel_sqlite-devel_zlib-devel_glibc-headers_glibc-devel_openssl-devel.log
Requirements installation failed with status: 1.
cf) 만약 위와 같은 에러가 나왔을때 에러로그를 확인하여 사용자 계정에 sudo 실행 권한이 없다고 나온다면 root 계정으로 들어가서 vi /etc/sudoers에다 redmine 계정에 커맨드 실행 권한을 한줄 추가해준다.
## Allow root to run any commands anywhere
root    ALL=(ALL)       ALL
redmine ALL=(ALL)       ALL
그 후 rvm 인스톨을 진행하면 현재 최신 버전인 2.6 이 설치가 된다.
[root@e3f23687c1ab ~]# ruby -v
ruby 2.6.0p0 (2018-12-25 revision 66547) [x86_64-linux]

루비를 설치하고 나니 gem 도 설치되어 있는 것을 확인할 수 있다.
[redmine@5a067717ed9e ~]$ gem -v
3.0.1
cf) ruby 문서 설치
rvm docs generate-ri

댓글 없음:

댓글 쓰기