LoginSignup
8
12

More than 3 years have passed since last update.

awsのec2にApacheを入れてwebサーバーとして使う

Posted at

0-1. 環境

aws - ec2 - ubuntu
インスタンスタイプ:t2.micro

0-2. 前提(今回作業前の状態)

awsアカウントは持ってた
一つインスタンスを作っていて、実行中のがあった
sshの設定なども済ませていて、すぐにログインできる状態

0-3. 大いに参考にさせて頂いたページたち

1. セキュリティーグループの設定

参考サイトの説明(下図)に従い、セキュリティーグループの設定
image.png

2. Apache2のインストール

パッケージの更新
sudo apt-get update

Apache2のインストール
sudo apt-get install apache2

バージョン確認
apache2 -v

IPv4 パブリック IPを確認し、自分のPCブラウザからアクセス
image.png
ok

トップページの箱(index.html)を作る

まず、ルートディレクトリを確認

vim /etc/apache2/sites-available/000-default.conf 

「DocumentRoot /var/www/html」っぽい

index.htmlを修正する

sudo vim /var/www/html/index.html 

以下のように記載

<!DOCTYPE html>
<html>
    <meta charset="utf-8">
    <head>
        <title>我が青春のホームページ</title>
    </head>
    <body>
        これがスマホとか他のパソコンから見れればOK
    </body>
</html>

インストール後に確認したのと同様に、IPv4 パブリック IPを確認し、自分のPCブラウザからアクセス
image.png
これで準備OK!
後日、中身を作ります(flaskと何かのAPIを使う想定)
 おわり

8
12
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
8
12