우분투 2204에서 Ruby 2를 설치하는 방법
우분투 22.04 환경에서 특정 프로젝트를 위해 Ruby 2 버전대(예: 2.7.6)가 필요한 경우 버전 관리 도구인 rbenv를 사용하는 것이 가장 깔끔하고 안전합니다.
테스트 환경
운영체제 정보
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 22.04.1 LTS
Release: 22.04
Codename: jammy
필수 의존성 패키지 설치
sudo apt-get update
sudo apt-get install -y git curl libssl-dev libreadline-dev zlib1g-dev
rbenv 및 ruby-build 설치
rbenv 리포지토리 클론
git clone https://github.com/rbenv/rbenv.git ~/.rbenv
환경 변수 등록
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
변경사항 적용
source ~/.bashrc
exec $SHELL
ruby-build 플러그인 설치
ruby-build 클론
git clone https://github.com/rbenv/ruby-build.git "$(rbenv root)"/plugins/ruby-build
echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc
버전 확인
rbenv versions
Ruby 2 설치
rbenv를 통해 원하는 Ruby 버전을 설치합니다. 우분투 22.04는 OpenSSL 3을 기본으로 사용하지만 ruby-build가 필요한 경우 이전 버전의 OpenSSL을 자동으로 함께 빌드하여 설치해 줍니다.
Ruby 2.7.6 설치
rbenv install 2.7.6
To follow progress, use 'tail -f /tmp/ruby-build.20221222144042.50871.log' or pass --verbose
Downloading openssl-1.1.1s.tar.gz...
-> https://dqw8nmjcqpjn7.cloudfront.net/c5ac01e760ee6ff0dab61d6b2bbd30146724d063eb322180c6f18a6f74e4b6aa
Installing openssl-1.1.1s...
Installed openssl-1.1.1s to /root/.rbenv/versions/2.7.6
Downloading ruby-2.7.6.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.7/ruby-2.7.6.tar.bz2
Installing ruby-2.7.6...
WARNING: ruby-2.7.6 is nearing its end of life.
It only receives critical security updates, no bug fixes.
Installed ruby-2.7.6 to /root/.rbenv/versions/2.7.6
NOTE: to activate this Ruby version as the new default, run: rbenv global 2.7.6
사용 가능한 버전 확인
rbenv versions
전역(Global) 버전 설정 및 확인
전역 설정
rbenv global 2.7.6
쉘 재실행 또는 rehash
rbenv rehash
버전 확인
ruby --version
심볼릭 링크 설정
ln -s /root/.rbenv/shims/ruby /bin/ruby
rbenv 사용법
rbenv
rbenv 1.1.2
Usage: rbenv <command> [<args>]
Some useful rbenv commands are:
commands List all available rbenv commands
local Set or show the local application-specific Ruby version
global Set or show the global Ruby version
shell Set or show the shell-specific Ruby version
install Install a Ruby version using ruby-build
uninstall Uninstall a specific Ruby version
rehash Rehash rbenv shims (run this after installing executables)
version Show the current Ruby version and its origin
versions List installed Ruby versions
which Display the full path to an executable
whence List all Ruby versions that contain the given executable
See `rbenv help <command>' for information on a specific command.
For full documentation, see: https://github.com/rbenv/rbenv#readme
rbenv를 통해 Ruby 2를 우분투에 성공적으로 설치하였습니다.
참고URL
- ruby latest version : https://rubychangelog.com/versions-latest/
'리눅스' 카테고리의 다른 글
| [draft] CentOS 7에서 Go 언어를 설치하는 방법 (0) | 2026.01.19 |
|---|---|
| [draft] 우분투 "sudo: cd: command not found" 오류 (0) | 2026.01.19 |
| [draft] CentOS 7에서 PHP-FPM 8.1을 설치하는 방법 (0) | 2026.01.19 |
| [draft] Amazon Linux 2에 PHP 8을 설치하는 방법 (0) | 2026.01.19 |
| [draft] 우분투 22.04에서 Samba 서버를 설치하고 구성하는 방법 (0) | 2026.01.18 |