RVM을 사용하여 데비안에 Ruby를 설치하는 방법

RVM을 사용하여 데비안에 Ruby를 설치하는 방법

2022-10-18 last update

6 minutes reading Ruby on Rails debian rails ruby rvm
Ruby는 많은 개발자들 사이에서 인기 있는 프로그래밍 언어입니다. Rails는 루비 언어를 실행하기 위한 프레임워크입니다. Ruby 언어는 Yukihiro "Matz"Matsumoto에 의해 만들어졌으며 1995년에 처음 출판되었습니다. 이 기사는 RVM을 사용하여 데비안 리눅스 시스템에서 레일에 루비를 설치하는 데 도움이 될 것입니다. RVM은 Node.js용 NVM과 유사한 Ruby 언어를 설치하고 관리하는 데 도움이 되는 Ruby 버전 관리자입니다.

1단계 – 전제 조건

GUI를 사용하여 데비안 시스템에 로그인하거나 원격 호스트에 ssh를 사용합니다. 그런 다음 몇 가지 사전 필수 패키지를 설치합니다.
sudo apt update 
sudo apt install curl gnupg2 

2단계 – RVM 설치

Before installing RVM first we need to import public key in our system then use curl to install rvm in our system.

curl -sSL https://rvm.io/mpapis.asc | sudo gpg2 --import - 
curl -sSL https://rvm.io/pkuczynski.asc | sudo gpg2 --import - 
curl -sSL https://get.rvm.io | sudo bash -s stable 

After installing RVM first we need to set up rvm environment using below command. so that current shell takes new environment settings.

source /etc/profile.d/rvm.sh 

After this, install all the dependencies for installing Ruby automatically on the system. Run below command on terminal.

rvm requirements 

3단계 – 사용 가능한 Ruby 버전 나열

Get a list of available versions of Ruby language. You can install any version of your choice or requirements showing on the list.

rvm list known
[ruby-]1.8.6[-p420]
[ruby-]1.8.7[-head] # security released on head
[ruby-]1.9.1[-p431]
[ruby-]1.9.2[-p330]
[ruby-]1.9.3[-p551]
[ruby-]2.0.0[-p648]
[ruby-]2.1[.10]
[ruby-]2.2[.10]
[ruby-]2.3[.8]
[ruby-]2.4[.9]
[ruby-]2.5[.7]
[ruby-]2.6[.5]
[ruby-]2.7[.0]
ruby-head

4단계 - 데비안에 Ruby 설치

RVM은 단일 시스템에 여러 Ruby 버전을 설치하는 데 유용합니다. 다음 명령을 사용하여 시스템에 필요한 Ruby를 설치합니다. 아래 예제와 같이 데비안 시스템에 Ruby 2.6을 설치합니다.
rvm install 2.7 
[샘플 출력]
Searching for binary rubies, this might take some time.
No binary rubies available for: centos/8/x86_64/ruby-2.7.0.
Continuing with compilation. Please read 'rvm help mount' to get more information on binary rubies.
Checking requirements for centos.
Requirements installation successful.
Installing Ruby from source to: /usr/local/rvm/rubies/ruby-2.7.0, this may take a while depending on your cpu(s)...
ruby-2.7.0 - #downloading ruby-2.7.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 14.0M  100 14.0M    0     0   107M      0 --:--:-- --:--:-- --:--:--  107M
ruby-2.7.0 - #extracting ruby-2.7.0 to /usr/local/rvm/src/ruby-2.7.0.....
ruby-2.7.0 - #configuring........................................................................
ruby-2.7.0 - #post-configuration..
ruby-2.7.0 - #compiling.....................-
.......................................................................
ruby-2.7.0 - #installing..................
ruby-2.7.0 - #making binaries executable...
Installed rubygems 3.1.2 is newer than 3.0.8 provided with installed ruby, skipping installation, use --force to force installation.
ruby-2.7.0 - #gemset created /usr/local/rvm/gems/[email protected]
ruby-2.7.0 - #importing gemset /usr/local/rvm/gemsets/global.gems................................................................
ruby-2.7.0 - #generating global wrappers.......
ruby-2.7.0 - #gemset created /usr/local/rvm/gems/ruby-2.7.0
ruby-2.7.0 - #importing gemsetfile /usr/local/rvm/gemsets/default.gems evaluated to empty gem list
ruby-2.7.0 - #generating default wrappers.......
ruby-2.7.0 - #adjusting #shebangs for (gem irb erb ri rdoc testrb rake).
Install of ruby-2.7.0 - #complete
Ruby was built without documentation, to build it run: rvm docs generate-ri

5단계 - 기본 Ruby 버전 설정

rvm 명령을 사용하여 응용 프로그램에서 사용할 기본 루비 버전을 설정합니다. 위 단계에서 정의한 대로 여러 버전을 설치할 수 있습니다. 이제 사용할 버전을 선택하십시오.
rvm use 2.7 --default  

Using /usr/local/rvm/gems/ruby-2.7.0

6단계 - Ruby 버전 확인

다음 명령을 사용하여 현재 사용 중인 루비 버전을 확인할 수 있습니다.
ruby --version 

ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x86_64-linux]

7단계 - 레일 설치

다음 명령을 실행하여 최신 안정 릴리스 버전의 Rails를 설치할 수 있습니다. 모든 애플리케이션이 동일한 버전의 Rails를 공유하도록 전역 gemset에 Rails를 설치합니다.
gem install rails 
rails -v 
또는 설치 중에 --version을 정의하여 특정 버전의 Rails를 얻을 수 있습니다. Visit here 사용 가능한 레일 버전을 얻으려면.
gem install rails --version=5.2.3 
축하합니다. 시스템에 Ruby를 성공적으로 설치했습니다. 다음 기사를 읽고 간단한 단계로 웹 서버를 배포Ruby with Apache 또는 Ruby with Nginx 하십시오.