I had to install Ruby on an EC2 instance to use ServerSpec, but it was unexpectedly difficult, so I summarized the procedure. (Mainly as a memorandum.) I think you can install it quickly without getting caught!
--EC2 instance
SSH connection when EC2 starts
rbenv is a Ruby version control tool
1 Update for the time being
$ sudo yum update -y
2 Install git
$ sudo yum install git -y
3 Clone rbenv from repository
$ git clone https://github.com/sstephenson/rbenv.git ~/.rbenv
4 After cloning, put it in the rbenv PATH
$ echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
$ echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
$ source ~/.bash_profile
5 If the version of rbenv is displayed, the installation is successful.
$ rbenv -v
The rbenv plugin required when installing Ruby via rbenv. Ruby cannot be installed without this.
1 Clone from repository
$ git clone git://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
2 Perform installation
$ cd ~/.rbenv/plugins/ruby-build
$ sudo ./install.sh
3 If the list of installable Ruby versions is displayed, ruby-build installation is successful.
$ rbenv install -l
1 Install the packages required for Ruby installation
$ sudo yum -y install gcc-c++ glibc-headers openssl-devel readline libyaml-devel readline-devel zlib zlib-devel libffi-devel libxml2 libxslt libxml2-devel libxslt-devel sqlite-devel
2 Install Ruby by specifying the version with rbenv (It takes a long time. The screen does not move at all, but the installation is proceeding)
$ rbenv install 2.7.0
$ #Version 2.7.Install 0
3 Specify the version of Ruby to be used in rbenv
$ rbenv global 2.7.0
4 Check the Ruby version (successful if the version you specified earlier is displayed ~> 2.7.0)
$ ruby -v
I think there are a lot of articles like this, but I got stuck somewhere, so I tried to raise the procedure that was successful again. I would be happy if it was helpful.
Recommended Posts