LoginSignup
6
4

More than 3 years have passed since last update.

AWS EC2でhello world

Last updated at Posted at 2019-10-21

AWSアカウントを作成してからEC2にApacheを入れてhello worldを表示するまでのメモ
使用OSはWindows
EC2インスタンスの作成方法とElasticIPの関連付けなどは省略

キーペア作成

画面左の選択欄から キーペア > キーペアの作成 を選択、適当なキーペア名を入力後作成ボタンをクリックし、「キーペア名.pem」をダウンロード
インスタンス一覧画面のキー名のところに作成したキーペアが登録されていることを確認
image.png

TeraTermで接続

接続先のインスタンスのIPv4パブリックIPを入力してOKボタンをクリック
image.png
ユーザ名にec2-userを入力、先ほどダウンロードした認証キーを設定
image.png
接続完了
image.png

Apacheをインストールして起動

// パッケージ更新
$ sudo yum update -y

// Apacheのインストール
$ sudo yum install -y httpd

// Apacheの起動
$ sudo service httpd start
// htmlファイル作成
$ sudo vim /var/www/html/index.html

$ cat /var/www/html/index.html
hello world!

ブラウザから確認

その前にポートを開いておく
セキュリティグループ > アクション > インバウンドのルールの編集
タイプをHTTPにして追加
image.png

インスタンス > パブリックDNS(IPv4)にあるアドレスにブラウザからアクセスすれば、hello worldが表示される

6
4
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
6
4