0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

EC2 初期セットアップ手順まとめ

Posted at

AWS EC2を新規で立ち上げたときに最低限やるべき初期設定の流れ

  1. 鍵ペアの作成とダウンロード
  --key-name my-key-pair \
  --key-type rsa \
  --key-format pem \
  --query "KeyMaterial" \
  --output text > ~/.ssh/my-key-pair.pem

chmod 400 ~/.ssh/my-key-pair.pem
  1. EC2にSSH接続
ssh -i ~/.ssh/my-key-pair.pem ec2-user@<EC2のパブリックIP>
  1. Git, rbenv, Rubyのセットアップ
git clone https://github.com/rbenv/rbenv.git ~/.rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
source ~/.bash_profile

git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
rbenv install 3.2.2
rbenv global 3.2.2
ruby -v
  1. MariaDB(MySQL互換)をHomebrewでインストール(Amazon Linuxじゃない場合)
brew services start mariadb

MariaDBの初期設定

mariadb-secure-installation

(rootパスワードの設定、匿名ユーザー削除、リモートroot拒否など)

  1. MySQLにログイン
mysql -u root -p
  1. その他よく使うLinuxコマンド
cd ..               # ひとつ上のディレクトリへ
ls -la              # 隠しファイルも含めて中身を表示
cat ファイル名      # ファイルの中身を確認
  1. よくあるエラーと対処

Permission denied (publickey)→ 鍵ファイルのパーミッションを確認 chmod 400
command not found→ yum Macの場合Homebrewで代用可能
.bash_profileがない→ touch ~/.bash_profile で作成可

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?