
この記事では
・EC2にApacheをインストールする手順
を紹介します!

また
・Apacheへ接続できるように
・セキュリティグループの設定の変更
も実施します!
前提
・EC2が作成済みであること
・EC2へリモートログインできること
EC2にApacheをインストール
EC2へリモートログインして、コマンドでApacheのインストールと起動を実行する。
Apacheのインストール
sudo yum install -y httpd


Apacheの起動
sudo systemctl start httpd.service

セキュリティグループの設定を変更
今回は
・対象EC2に既に紐づいているセキュリティグループの設定を変更
します。
※セキュリティグループを新規作成して、それの設定を変更するのではなく。
セキュリティグループに、以下の2つの通信が可能となるように、ルールを追加します。
・HTTP
・HTTPS
手順
セキュリティグループの一覧のページを表示する。
手順
対象の「セキュリティグループ」にチェックを入れた状態、タブ「インバウンドルール」の「インバウンドルールの編集」をクリックする。

手順
「ルールの追加」をクリックして、以下の2つのルールを追加する
・「タイプ:HTTP」、「ソース:Anywhere-IPv4」 ※自動で「0.0.0.0」が設定される
・「タイプ:HTTPS」、「ソース:Anywhere-IPv4」 ※自動で「0.0.0.0」が設定される

手順
「ルールを保存」をクリックする。

上記の実施により、インバウンドルールが2つ追加されました。

Apacheへ接続
ブラウザで「http://EC2のパブリック IPv4 アドレス」へアクセスすると、Apacheへ接続できることを確認できました。
※「It works!」のページが表示されました。
