우분투 rbenv ruby 설치

1 라이브러리 설치[ | ]

root@zetawiki:~# apt-get install libssl-dev libreadline-dev zlib1g-dev
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following extra packages will be installed:
  libreadline6-dev libssl-doc libssl1.0.0 libtinfo-dev
The following NEW packages will be installed:
  libreadline-dev libreadline6-dev libssl-dev libssl-doc libtinfo-dev
  zlib1g-dev
The following packages will be upgraded:
  libssl1.0.0
1 upgraded, 6 newly installed, 0 to remove and 74 not upgraded.
Need to get 3,346 kB of archives.
After this operation, 9,581 kB of additional disk space will be used.
Do you want to continue? [Y/n]
Get:1 http://us.archive.ubuntu.com/ubuntu/ trusty-updates/main libssl1.0.0 amd64 1.0.1f-1ubuntu2.19 [828 kB]
Get:2 http://us.archive.ubuntu.com/ubuntu/ trusty/main libtinfo-dev amd64 5.9+20140118-1ubuntu1 [76.3 kB]
Get:3 http://us.archive.ubuntu.com/ubuntu/ trusty/main libreadline6-dev amd64 6.3-4ubuntu2 [213 kB]
Get:4 http://us.archive.ubuntu.com/ubuntu/ trusty/main libreadline-dev amd64 6.3-4ubuntu2 [988 B]
Get:5 http://us.archive.ubuntu.com/ubuntu/ trusty/main zlib1g-dev amd64 1:1.2.8.dfsg-1ubuntu1 [183 kB]
Get:6 http://us.archive.ubuntu.com/ubuntu/ trusty-updates/main libssl-dev amd64 1.0.1f-1ubuntu2.19 [1,073 kB]
Get:7 http://us.archive.ubuntu.com/ubuntu/ trusty-updates/main libssl-doc all 1.0.1f-1ubuntu2.19 [971 kB]
Fetched 3,346 kB in 3s (896 kB/s)
Preconfiguring packages ...
(Reading database ... 63851 files and directories currently installed.)
Preparing to unpack .../libssl1.0.0_1.0.1f-1ubuntu2.19_amd64.deb ...
Unpacking libssl1.0.0:amd64 (1.0.1f-1ubuntu2.19) over (1.0.1f-1ubuntu2.18) ...
Selecting previously unselected package libtinfo-dev:amd64.
Preparing to unpack .../libtinfo-dev_5.9+20140118-1ubuntu1_amd64.deb ...
Unpacking libtinfo-dev:amd64 (5.9+20140118-1ubuntu1) ...
Selecting previously unselected package libreadline6-dev:amd64.
Preparing to unpack .../libreadline6-dev_6.3-4ubuntu2_amd64.deb ...
Unpacking libreadline6-dev:amd64 (6.3-4ubuntu2) ...
Selecting previously unselected package libreadline-dev:amd64.
Preparing to unpack .../libreadline-dev_6.3-4ubuntu2_amd64.deb ...
Unpacking libreadline-dev:amd64 (6.3-4ubuntu2) ...
Selecting previously unselected package zlib1g-dev:amd64.
Preparing to unpack .../zlib1g-dev_1%3a1.2.8.dfsg-1ubuntu1_amd64.deb ...
Unpacking zlib1g-dev:amd64 (1:1.2.8.dfsg-1ubuntu1) ...
Selecting previously unselected package libssl-dev:amd64.
Preparing to unpack .../libssl-dev_1.0.1f-1ubuntu2.19_amd64.deb ...
Unpacking libssl-dev:amd64 (1.0.1f-1ubuntu2.19) ...
Selecting previously unselected package libssl-doc.
Preparing to unpack .../libssl-doc_1.0.1f-1ubuntu2.19_all.deb ...
Unpacking libssl-doc (1.0.1f-1ubuntu2.19) ...
Processing triggers for install-info (5.2.0.dfsg.1-2) ...
Processing triggers for man-db (2.6.7.1-1ubuntu1) ...
Setting up libssl1.0.0:amd64 (1.0.1f-1ubuntu2.19) ...
Setting up libtinfo-dev:amd64 (5.9+20140118-1ubuntu1) ...
Setting up libreadline6-dev:amd64 (6.3-4ubuntu2) ...
Setting up libreadline-dev:amd64 (6.3-4ubuntu2) ...
Setting up zlib1g-dev:amd64 (1:1.2.8.dfsg-1ubuntu1) ...
Setting up libssl-dev:amd64 (1.0.1f-1ubuntu2.19) ...
Setting up libssl-doc (1.0.1f-1ubuntu2.19) ...
Processing triggers for libc-bin (2.19-0ubuntu6.7) ...

2 useradd[ | ]

root@zetawiki:~# useradd railsuser -m -s /bin/bash
root@zetawiki:~# su - railsuser
railsuser@zetawiki:~$ pwd
/home/railsuser

3 rbenv 클론[ | ]

git clone https://github.com/rbenv/rbenv.git ~/.rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
exec $SHELL
echo $PATH
railsuser@zetawiki:~$ git clone https://github.com/rbenv/rbenv.git ~/.rbenv
Cloning into '/home/railsuser/.rbenv'...
remote: Counting objects: 2500, done.
remote: Total 2500 (delta 0), reused 0 (delta 0), pack-reused 2500
Receiving objects: 100% (2500/2500), 456.36 KiB | 276.00 KiB/s, done.
Resolving deltas: 100% (1546/1546), done.
Checking connectivity... done.
railsuser@zetawiki:~$ echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
railsuser@zetawiki:~$ echo 'eval "$(rbenv init -)"' >> ~/.bashrc
railsuser@zetawiki:~$ exec $SHELL
railsuser@zetawiki:~$ echo $PATH
/home/railsuser/.rbenv/shims:/home/railsuser/.rbenv/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games

4 ruby-build 클론[ | ]

git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bashrc
exec $SHELL
echo $PATH
railsuser@zetawiki:~$ git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
Cloning into '/home/railsuser/.rbenv/plugins/ruby-build'...
remote: Counting objects: 6454, done.
remote: Compressing objects: 100% (7/7), done.
remote: Total 6454 (delta 2), reused 0 (delta 0), pack-reused 6446
Receiving objects: 100% (6454/6454), 1.25 MiB | 266.00 KiB/s, done.
Resolving deltas: 100% (3720/3720), done.
Checking connectivity... done.
railsuser@zetawiki:~$ echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bashrc
railsuser@zetawiki:~$ exec $SHELL
railsuser@zetawiki:~$ echo $PATH
/home/railsuser/.rbenv/plugins/ruby-build/bin:/home/railsuser/.rbenv/shims:/home/railsuser/.rbenv/bin:/home/railsuser/.rbenv/shims:/home/railsuser/.rbenv/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games

5 rbenv-gem-rehash 클론[ | ]

git clone https://github.com/rbenv/rbenv-gem-rehash.git ~/.rbenv/plugins/rbenv-gem-rehash
railsuser@zetawiki:~$ git clone https://github.com/rbenv/rbenv-gem-rehash.git ~/.rbenv/plugins/rbenv-gem-rehash
Cloning into '/home/railsuser/.rbenv/plugins/rbenv-gem-rehash'...
remote: Counting objects: 97, done.
remote: Total 97 (delta 0), reused 0 (delta 0), pack-reused 97
Unpacking objects: 100% (97/97), done.
Checking connectivity... done.

6 루비 설치 (실패)[ | ]

rbenv install 2.3.1
railsuser@zetawiki:~$ rbenv install 2.3.1
/home/railsuser/.rbenv/plugins/ruby-build/bin/ruby-build: /usr/bin/shasum: /usr/bin/perl: bad interpreter: Permission denied
Downloading ruby-2.3.1.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.3/ruby-2.3.1.tar.bz2
error: failed to download ruby-2.3.1.tar.bz2

BUILD FAILED (Ubuntu 14.04 using ruby-build 20160602-2-ga73c427)

7 (Optional) 퍼미션 조정[ | ]

  • railsuser 계정으로 설치를 진행하다보니, perl, curl, make 권한이 없어 막히더라.
  • root 계정으로 실행권한을 주자.
root@zetawiki:~# ll /usr/bin/perl
-rwx------ 2 root root 10416 Mar  2 02:36 /usr/bin/perl*
root@zetawiki:~# ll /usr/bin/make
-rwx------ 1 root root 170088 Jun  9  2013 /usr/bin/make*
root@zetawiki:~# chmod +x /usr/bin/perl
root@zetawiki:~# chmod +x /usr/bin/curl
root@zetawiki:~# chmod +x /usr/bin/make
root@zetawiki:~# ll /usr/bin/perl
-rwx--x--x 2 root root 10416 Mar  2 02:36 /usr/bin/perl*
root@zetawiki:~# ll /usr/bin/curl
-rwx--x--x 1 root root 154328 Jan 27 05:05 /usr/bin/curl*
root@zetawiki:~# ll /usr/bin/make
-rwx--x--x 1 root root 170088 Jun  9  2013 /usr/bin/make*

8 루비 설치[ | ]

rbenv install --verbose 2.3.1
railsuser@zetawiki:~$ rbenv install --verbose 2.3.1
/tmp/ruby-build.20160606180139.9945 ~
Downloading ruby-2.3.1.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.3/ruby-2.3.1.tar.bz2
/tmp/ruby-build.20160606180139.9945/ruby-2.3.1 /tmp/ruby-build.20160606180139.9945 ~
Installing ruby-2.3.1...
checking for ruby... /usr/bin/ruby
... (생략)
installing rdoc:              /home/railsuser/.rbenv/versions/2.3.1/share/ri/2.3.0/system
installing capi-docs:         /home/railsuser/.rbenv/versions/2.3.1/share/doc/ruby
/tmp/ruby-build.20160606180139.9945 ~
~
Installed ruby-2.3.1 to /home/railsuser/.rbenv/versions/2.3.1

9 루비 설정 및 확인[ | ]

rbenv global 2.3.1
ruby -v
railsuser@zetawiki:~$ rbenv versions
* system (set by /home/railsuser/.rbenv/version)
  2.3.1
railsuser@zetawiki:~$ rbenv global 2.3.1
railsuser@zetawiki:~$ rbenv versions
  system
* 2.3.1 (set by /home/railsuser/.rbenv/version)
railsuser@zetawiki:~$ ruby -v
ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-linux]

10 같이 보기[ | ]

11 참고[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}