AWSのEC2を使ってサーバーを作成④
ec2-userでログイン
ターミナル(ローカル)
$ cd ~ $ mkdir ~/.ssh(.sshディレクトリというディレクトリがあれば省略です) $ mv Downloads/ダウンロードした鍵の名前.pem .ssh/ $ cd .ssh/ $ chmod 600 ダウンロードした鍵の名前.pem $ ssh -i ダウンロードした鍵の名前.pem ec2-user@作成したEC2インスタンスと紐付けたElastic IP
ターミナル(ローカル)
Are you sure you want to continue connecting (yes/no)?
と出た場合はyesを選択します。
ターミナル
こんな感じになればログインできてます。
EC2のRuby/Rails環境構築①
設定用のツールをインストール
ターミナル(サーバー)
$ sudo yum -y update $ sudo yum -y install git make gcc-c++ patch libyaml-devel libffi-devel libicu-devel zlib-devel readline-devel libxml2-devel libxslt-devel ImageMagick ImageMagick-devel openssl-devel libcurl libcurl-devel curl
Node.jsをインストール
$ sudo curl -sL https://rpm.nodesource.com/setup_6.x | sudo bash - $ sudo yum -y install nodejs
rbenvとruby-buildをインストール
#rbenvのインストール [ec2-user@ip-172-31-25-189 ~]$ git clone https://github.com/sstephenson/rbenv.git ~/.rbenv #パスを通す [ec2-user@ip-172-31-25-189 ~]$ echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile #rbenvを呼び出すための記述 [ec2-user@ip-172-31-25-189 ~]$ echo 'eval "$(rbenv init -)"' >> ~/.bash_profile #.bash_profileの読み込み [ec2-user@ip-172-31-25-189 ~]$ source .bash_profile #ruby-buildのインストール [ec2-user@ip-172-31-25-189 ~]$ git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build #rehashを行う [ec2-user@ip-172-31-25-189 ~]$ rbenv rehash
Rubyをインストール
$ rbenv install 2.5.1 $ rbenv global 2.5.1 $ rbenv rehash