LoginSignup
0
0

More than 3 years have passed since last update.

AWS (Amazon Web Service) 登録とWebサーバー (Nginx)公開設定まで

Last updated at Posted at 2021-04-17

https://aws.amazon.com/jp/s/dm/landing-page/create-free-account
より、AWS アカウントを作成し Amazon EC2 を1年間無料でお試し登録。

https://us-east-2.console.aws.amazon.com/console/home?region=us-east-2
AWS マネジメントコンソール
より「仮想マシンを起動する」を選択してEC2を使用開始する。

ステップ 1: Amazon マシンイメージ (AMI)

AWS_AMI.png
インスタンスの作成に必要なソフトウェア構成 (OS、アプリケーションサーバー、アプリケーション) を含むAmazonマシンイメージ(AMI)を選択する。ここでは一番基本的な「Amazon Linux 2 AMI 64 ビット (x86)」を選択

ステップ 2: インスタンスタイプの選択

インスタンスとは、アプリケーションを実行できる仮想サーバーで、
インスタンスタイプとは、様々なCPU、メモリ、ストレージ、ネットワークキャパシティの組み合わせの構成のこと。
ここでは無料利用枠対象の「t2.micro」 1CPU/1GiBメモリ/NWパフォーマンス[低から中] etc を選択

ステップ 3: インスタンスの詳細の設定

要件に合わせてインスタンスを設定する。ここではすべて初期設定のままとした。

ステップ 4: ストレージの追加

インスタンスのストレージデバイス設定として、無料利用枠の 8GiB 汎用SSD(gp2) /dev/xvda 暗号化なし を利用

ステップ 5: タグの追加

タグは、大文字と小文字が区別されるキーと値のペアから構成されます。たとえば、キーに「Name」、値に「Webserver」を使用してタグを定義することができます。
とりあえずなしですすめる

ステップ 6: セキュリティグループの設定

ポート22が初期設定されている。
なお自分のPCからインスタンスの設定をSSHで行うのに、接続元を「マイIP」からに限定する。
AWS_InstanceSecurityGpSetting.png

キーペアの作成

ここで「起動」を実行すると下記が表示される
既存のキーペアを選択するか、新しいキーペアを作成します。
AWS_Instance_KeypairInput.png

キーペアは、AWS が保存するパブリックキーとユーザーが保存するプライベートキーファイルで構成され組み合わせて使用することで、インスタンスに安全に接続できます。Linux AMI の場合、プライベートキーファイルを使用してインスタンスに SSH で安全に接続できます。

のようなので、キーペア名を入力し、*.pemファイルをダウンロードして自分のPCに保存しておく。

インスタンスへのSSH接続

なおPCからSSH接続を試すと、下記のようにpemファイルの権限が弱いとのエラーとなるため、

ssh -i /********.pem ec2-user@xxxxxxxxxxxxxxxxxxxxx

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@         WARNING: UNPROTECTED PRIVATE KEY FILE!          @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0644 for '/********..pem' are too open.
It is required that your private key files are NOT accessible by others.
This private key will be ignored.
Load key "/********.pem": bad permissions
ec2-user@xxxxxxxxxxxxxxxxxxxxx: Permission denied (publickey,gssapi-keyex,gssapi-with-mic).

ダウンロードした pemファイルの権限を下記のように自分からのみ見えるように修正すること。

$ chmod 400 /********.pem

再度SSH接続を試すと接続OKとなった

$ ssh -i /********..pem ec2-user@xxxxxxxxxxxxxxxxxxxxx

       __|  __|_  )
       _|  (     /   Amazon Linux 2 AMI
      ___|\___|___|

https://aws.amazon.com/amazon-linux-2/
No packages needed for security; 2 packages available
Run "sudo yum update" to apply all updates.

Nginx Webサーバーのインストール

YUM update してやり、Nginx をインストール

$ sudo yum update
読み込んだプラグイン:extras_suggestions, langpacks, priorities, update-motd
依存性の解決をしています
--> トランザクションの確認を実行しています。
---> パッケージ amazon-ssm-agent.x86_64 0:3.0.161.0-1.amzn2 を 更新
---> パッケージ amazon-ssm-agent.x86_64 0:3.0.529.0-1.amzn2 を アップデート
(略)                              

更新:
  amazon-ssm-agent.x86_64 0:3.0.529.0-1.amzn2                                   
  aws-cfn-bootstrap.noarch 0:2.0-6.amzn2                                        

完了しました!

インストールは yum install nginx ではなく、amazon-linux-extras install nginx1 で行う必要ありとのこと。

$ sudo yum install nginx
読み込んだプラグイン:extras_suggestions, langpacks, priorities, update-motd
パッケージ nginx は利用できません。
エラー: 何もしません

nginx is available in Amazon Linux Extra topic "nginx1"

To use, run
# sudo amazon-linux-extras install nginx1

Learn more at
https://aws.amazon.com/amazon-linux-2/faqs/#Amazon_Linux_Extras



$ sudo amazon-linux-extras install nginx1
Installing nginx
読み込んだプラグイン:extras_suggestions, langpacks, priorities, update-motd
リポジトリーを清掃しています: amzn2-core amzn2extra-docker amzn2extra-nginx1
12 個の metadata ファイルを削除しました
4 個の sqlite ファイルを削除しました
0 個の metadata ファイルを削除しました
読み込んだプラグイン:extras_suggestions, langpacks, priorities, update-motd
amzn2-core                                               | 3.7 kB     00:00     
amzn2extra-docker                                        | 3.0 kB     00:00     
amzn2extra-nginx1                                        | 3.0 kB     00:00     
(1/7): amzn2-core/2/x86_64/group_gz                        | 2.5 kB   00:00     
(2/7): amzn2-core/2/x86_64/updateinfo                      | 362 kB   00:00     
(3/7): amzn2extra-nginx1/2/x86_64/primary_db               |  23 kB   00:00     
(4/7): amzn2extra-nginx1/2/x86_64/updateinfo               |   76 B   00:00     
(5/7): amzn2extra-docker/2/x86_64/updateinfo               |   76 B   00:00     
(6/7): amzn2extra-docker/2/x86_64/primary_db               |  76 kB   00:00     
(7/7): amzn2-core/2/x86_64/primary_db                      |  51 MB   00:00     
依存性の解決をしています
--> トランザクションの確認を実行しています。
---> パッケージ nginx.x86_64 1:1.18.0-1.amzn2.0.2 を インストール
--> 依存性の処理をしています: nginx-filesystem = 1:1.18.0-1.amzn2.0.2 のパッケージ: 1:nginx-1.18.0-1.amzn2.0.2.x86_64
--> 依存性の処理をしています: nginx-all-modules = 1:1.18.0-1.amzn2.0.2 のパッケージ: 1:nginx-1.18.0-1.amzn2.0.2.x86_64
--> 依存性の処理をしています: nginx-filesystem のパッケージ: 1:nginx-1.18.0-1.amzn2.0.2.x86_64
--> 依存性の処理をしています: libprofiler.so.0()(64bit) のパッケージ: 1:nginx-1.18.0-1.amzn2.0.2.x86_64
--> トランザクションの確認を実行しています。
---> パッケージ gperftools-libs.x86_64 0:2.6.1-1.amzn2 を インストール
---> パッケージ nginx-all-modules.noarch 1:1.18.0-1.amzn2.0.2 を インストール
--> 依存性の処理をしています: nginx-mod-stream = 1:1.18.0-1.amzn2.0.2 のパッケージ: 1:nginx-all-modules-1.18.0-1.amzn2.0.2.noarch
--> 依存性の処理をしています: nginx-mod-mail = 1:1.18.0-1.amzn2.0.2 のパッケージ: 1:nginx-all-modules-1.18.0-1.amzn2.0.2.noarch
--> 依存性の処理をしています: nginx-mod-http-xslt-filter = 1:1.18.0-1.amzn2.0.2 のパッケージ: 1:nginx-all-modules-1.18.0-1.amzn2.0.2.noarch
--> 依存性の処理をしています: nginx-mod-http-perl = 1:1.18.0-1.amzn2.0.2 のパッケージ: 1:nginx-all-modules-1.18.0-1.amzn2.0.2.noarch
--> 依存性の処理をしています: nginx-mod-http-image-filter = 1:1.18.0-1.amzn2.0.2 のパッケージ: 1:nginx-all-modules-1.18.0-1.amzn2.0.2.noarch
--> 依存性の処理をしています: nginx-mod-http-geoip = 1:1.18.0-1.amzn2.0.2 のパッケージ: 1:nginx-all-modules-1.18.0-1.amzn2.0.2.noarch
---> パッケージ nginx-filesystem.noarch 1:1.18.0-1.amzn2.0.2 を インストール
--> トランザクションの確認を実行しています。
---> パッケージ nginx-mod-http-geoip.x86_64 1:1.18.0-1.amzn2.0.2 を インストール
---> パッケージ nginx-mod-http-image-filter.x86_64 1:1.18.0-1.amzn2.0.2 を インストール
--> 依存性の処理をしています: gd のパッケージ: 1:nginx-mod-http-image-filter-1.18.0-1.amzn2.0.2.x86_64
--> 依存性の処理をしています: libgd.so.2()(64bit) のパッケージ: 1:nginx-mod-http-image-filter-1.18.0-1.amzn2.0.2.x86_64
---> パッケージ nginx-mod-http-perl.x86_64 1:1.18.0-1.amzn2.0.2 を インストール
---> パッケージ nginx-mod-http-xslt-filter.x86_64 1:1.18.0-1.amzn2.0.2 を インストール
--> 依存性の処理をしています: libxslt.so.1(LIBXML2_1.0.18)(64bit) のパッケージ: 1:nginx-mod-http-xslt-filter-1.18.0-1.amzn2.0.2.x86_64
--> 依存性の処理をしています: libxslt.so.1(LIBXML2_1.0.11)(64bit) のパッケージ: 1:nginx-mod-http-xslt-filter-1.18.0-1.amzn2.0.2.x86_64
--> 依存性の処理をしています: libxslt.so.1()(64bit) のパッケージ: 1:nginx-mod-http-xslt-filter-1.18.0-1.amzn2.0.2.x86_64
--> 依存性の処理をしています: libexslt.so.0()(64bit) のパッケージ: 1:nginx-mod-http-xslt-filter-1.18.0-1.amzn2.0.2.x86_64
---> パッケージ nginx-mod-mail.x86_64 1:1.18.0-1.amzn2.0.2 を インストール
---> パッケージ nginx-mod-stream.x86_64 1:1.18.0-1.amzn2.0.2 を インストール
--> トランザクションの確認を実行しています。
---> パッケージ gd.x86_64 0:2.0.35-27.amzn2 を インストール
--> 依存性の処理をしています: libfontconfig.so.1()(64bit) のパッケージ: gd-2.0.35-27.amzn2.x86_64
--> 依存性の処理をしています: libXpm.so.4()(64bit) のパッケージ: gd-2.0.35-27.amzn2.x86_64
--> 依存性の処理をしています: libX11.so.6()(64bit) のパッケージ: gd-2.0.35-27.amzn2.x86_64
---> パッケージ libxslt.x86_64 0:1.1.28-6.amzn2 を インストール
--> トランザクションの確認を実行しています。
---> パッケージ fontconfig.x86_64 0:2.13.0-4.3.amzn2 を インストール
--> 依存性の処理をしています: fontpackages-filesystem のパッケージ: fontconfig-2.13.0-4.3.amzn2.x86_64
--> 依存性の処理をしています: dejavu-sans-fonts のパッケージ: fontconfig-2.13.0-4.3.amzn2.x86_64
---> パッケージ libX11.x86_64 0:1.6.7-3.amzn2 を インストール
--> 依存性の処理をしています: libX11-common >= 1.6.7-3.amzn2 のパッケージ: libX11-1.6.7-3.amzn2.x86_64
--> 依存性の処理をしています: libxcb.so.1()(64bit) のパッケージ: libX11-1.6.7-3.amzn2.x86_64
---> パッケージ libXpm.x86_64 0:3.5.12-1.amzn2.0.2 を インストール
--> トランザクションの確認を実行しています。
---> パッケージ dejavu-sans-fonts.noarch 0:2.33-6.amzn2 を インストール
--> 依存性の処理をしています: dejavu-fonts-common = 2.33-6.amzn2 のパッケージ: dejavu-sans-fonts-2.33-6.amzn2.noarch
---> パッケージ fontpackages-filesystem.noarch 0:1.44-8.amzn2 を インストール
---> パッケージ libX11-common.noarch 0:1.6.7-3.amzn2 を インストール
---> パッケージ libxcb.x86_64 0:1.12-1.amzn2.0.2 を インストール
--> 依存性の処理をしています: libXau.so.6()(64bit) のパッケージ: libxcb-1.12-1.amzn2.0.2.x86_64
--> トランザクションの確認を実行しています。
---> パッケージ dejavu-fonts-common.noarch 0:2.33-6.amzn2 を インストール
---> パッケージ libXau.x86_64 0:1.0.8-2.1.amzn2.0.2 を インストール
--> 依存性解決を終了しました。

依存性を解決しました

================================================================================
 Package                    アーキテクチャー
                                   バージョン           リポジトリー       容量
================================================================================
インストール中:
 nginx                      x86_64 1:1.18.0-1.amzn2.0.2 amzn2extra-nginx1 560 k
依存性関連でのインストールをします:
 dejavu-fonts-common        noarch 2.33-6.amzn2         amzn2-core         64 k
 dejavu-sans-fonts          noarch 2.33-6.amzn2         amzn2-core        1.4 M
 fontconfig                 x86_64 2.13.0-4.3.amzn2     amzn2-core        253 k
 fontpackages-filesystem    noarch 1.44-8.amzn2         amzn2-core         10 k
 gd                         x86_64 2.0.35-27.amzn2      amzn2-core        146 k
 gperftools-libs            x86_64 2.6.1-1.amzn2        amzn2-core        274 k
 libX11                     x86_64 1.6.7-3.amzn2        amzn2-core        606 k
 libX11-common              noarch 1.6.7-3.amzn2        amzn2-core        164 k
 libXau                     x86_64 1.0.8-2.1.amzn2.0.2  amzn2-core         29 k
 libXpm                     x86_64 3.5.12-1.amzn2.0.2   amzn2-core         57 k
 libxcb                     x86_64 1.12-1.amzn2.0.2     amzn2-core        216 k
 libxslt                    x86_64 1.1.28-6.amzn2       amzn2-core        240 k
 nginx-all-modules          noarch 1:1.18.0-1.amzn2.0.2 amzn2extra-nginx1  20 k
 nginx-filesystem           noarch 1:1.18.0-1.amzn2.0.2 amzn2extra-nginx1  21 k
 nginx-mod-http-geoip       x86_64 1:1.18.0-1.amzn2.0.2 amzn2extra-nginx1  27 k
 nginx-mod-http-image-filter
                            x86_64 1:1.18.0-1.amzn2.0.2 amzn2extra-nginx1  30 k
 nginx-mod-http-perl        x86_64 1:1.18.0-1.amzn2.0.2 amzn2extra-nginx1  41 k
 nginx-mod-http-xslt-filter x86_64 1:1.18.0-1.amzn2.0.2 amzn2extra-nginx1  29 k
 nginx-mod-mail             x86_64 1:1.18.0-1.amzn2.0.2 amzn2extra-nginx1  58 k
 nginx-mod-stream           x86_64 1:1.18.0-1.amzn2.0.2 amzn2extra-nginx1  85 k

トランザクションの要約
================================================================================
インストール  1 パッケージ (+20 個の依存関係のパッケージ)

総ダウンロード容量: 4.3 M
インストール容量: 14 M
Is this ok [y/d/N]: y
Downloading packages:
(1/21): dejavu-fonts-common-2.33-6.amzn2.noarch.rpm        |  64 kB   00:00     
(2/21): dejavu-sans-fonts-2.33-6.amzn2.noarch.rpm          | 1.4 MB   00:00     
(3/21): fontconfig-2.13.0-4.3.amzn2.x86_64.rpm             | 253 kB   00:00     
(4/21): gd-2.0.35-27.amzn2.x86_64.rpm                      | 146 kB   00:00     
(5/21): fontpackages-filesystem-1.44-8.amzn2.noarch.rpm    |  10 kB   00:00     
(6/21): libX11-1.6.7-3.amzn2.x86_64.rpm                    | 606 kB   00:00     
(7/21): gperftools-libs-2.6.1-1.amzn2.x86_64.rpm           | 274 kB   00:00     
(8/21): libX11-common-1.6.7-3.amzn2.noarch.rpm             | 164 kB   00:00     
(9/21): libXpm-3.5.12-1.amzn2.0.2.x86_64.rpm               |  57 kB   00:00     
(10/21): libxcb-1.12-1.amzn2.0.2.x86_64.rpm                | 216 kB   00:00     
(11/21): libxslt-1.1.28-6.amzn2.x86_64.rpm                 | 240 kB   00:00     
(12/21): libXau-1.0.8-2.1.amzn2.0.2.x86_64.rpm             |  29 kB   00:00     
(13/21): nginx-1.18.0-1.amzn2.0.2.x86_64.rpm               | 560 kB   00:00     
(14/21): nginx-all-modules-1.18.0-1.amzn2.0.2.noarch.rpm   |  20 kB   00:00     
(15/21): nginx-mod-http-geoip-1.18.0-1.amzn2.0.2.x86_64.rp |  27 kB   00:00     
(16/21): nginx-mod-http-image-filter-1.18.0-1.amzn2.0.2.x8 |  30 kB   00:00     
(17/21): nginx-mod-http-perl-1.18.0-1.amzn2.0.2.x86_64.rpm |  41 kB   00:00     
(18/21): nginx-filesystem-1.18.0-1.amzn2.0.2.noarch.rpm    |  21 kB   00:00     
(19/21): nginx-mod-http-xslt-filter-1.18.0-1.amzn2.0.2.x86 |  29 kB   00:00     
(20/21): nginx-mod-mail-1.18.0-1.amzn2.0.2.x86_64.rpm      |  58 kB   00:00     
(21/21): nginx-mod-stream-1.18.0-1.amzn2.0.2.x86_64.rpm    |  85 kB   00:00     
--------------------------------------------------------------------------------
合計                                               7.6 MB/s | 4.3 MB  00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  インストール中          : fontpackages-filesystem-1.44-8.amzn2.noarch    1/21 
  インストール中          : dejavu-fonts-common-2.33-6.amzn2.noarch        2/21 
  インストール中          : dejavu-sans-fonts-2.33-6.amzn2.noarch          3/21 
  インストール中          : fontconfig-2.13.0-4.3.amzn2.x86_64             4/21 
  インストール中          : libxslt-1.1.28-6.amzn2.x86_64                  5/21 
  インストール中          : libXau-1.0.8-2.1.amzn2.0.2.x86_64              6/21 
  インストール中          : libxcb-1.12-1.amzn2.0.2.x86_64                 7/21 
  インストール中          : libX11-common-1.6.7-3.amzn2.noarch             8/21 
  インストール中          : libX11-1.6.7-3.amzn2.x86_64                    9/21 
  インストール中          : libXpm-3.5.12-1.amzn2.0.2.x86_64              10/21 
  インストール中          : gd-2.0.35-27.amzn2.x86_64                     11/21 
  インストール中          : 1:nginx-filesystem-1.18.0-1.amzn2.0.2.noarc   12/21 
  インストール中          : gperftools-libs-2.6.1-1.amzn2.x86_64          13/21 
  インストール中          : 1:nginx-mod-http-perl-1.18.0-1.amzn2.0.2.x8   14/21 
  インストール中          : 1:nginx-mod-stream-1.18.0-1.amzn2.0.2.x86_6   15/21 
  インストール中          : 1:nginx-mod-http-geoip-1.18.0-1.amzn2.0.2.x   16/21 
  インストール中          : 1:nginx-mod-mail-1.18.0-1.amzn2.0.2.x86_64    17/21 
  インストール中          : 1:nginx-mod-http-xslt-filter-1.18.0-1.amzn2   18/21 
  インストール中          : 1:nginx-1.18.0-1.amzn2.0.2.x86_64             19/21 
  インストール中          : 1:nginx-mod-http-image-filter-1.18.0-1.amzn   20/21 
  インストール中          : 1:nginx-all-modules-1.18.0-1.amzn2.0.2.noar   21/21 
  検証中                  : fontconfig-2.13.0-4.3.amzn2.x86_64             1/21 
  検証中                  : 1:nginx-mod-http-perl-1.18.0-1.amzn2.0.2.x8    2/21 
  検証中                  : 1:nginx-mod-stream-1.18.0-1.amzn2.0.2.x86_6    3/21 
  検証中                  : libX11-1.6.7-3.amzn2.x86_64                    4/21 
  検証中                  : gperftools-libs-2.6.1-1.amzn2.x86_64           5/21 
  検証中                  : 1:nginx-mod-http-geoip-1.18.0-1.amzn2.0.2.x    6/21 
  検証中                  : 1:nginx-filesystem-1.18.0-1.amzn2.0.2.noarc    7/21 
  検証中                  : 1:nginx-mod-mail-1.18.0-1.amzn2.0.2.x86_64     8/21 
  検証中                  : libxcb-1.12-1.amzn2.0.2.x86_64                 9/21 
  検証中                  : dejavu-sans-fonts-2.33-6.amzn2.noarch         10/21 
  検証中                  : 1:nginx-mod-http-xslt-filter-1.18.0-1.amzn2   11/21 
  検証中                  : 1:nginx-mod-http-image-filter-1.18.0-1.amzn   12/21 
  検証中                  : dejavu-fonts-common-2.33-6.amzn2.noarch       13/21 
  検証中                  : fontpackages-filesystem-1.44-8.amzn2.noarch   14/21 
  検証中                  : gd-2.0.35-27.amzn2.x86_64                     15/21 
  検証中                  : libX11-common-1.6.7-3.amzn2.noarch            16/21 
  検証中                  : 1:nginx-1.18.0-1.amzn2.0.2.x86_64             17/21 
  検証中                  : libXau-1.0.8-2.1.amzn2.0.2.x86_64             18/21 
  検証中                  : libxslt-1.1.28-6.amzn2.x86_64                 19/21 
  検証中                  : 1:nginx-all-modules-1.18.0-1.amzn2.0.2.noar   20/21 
  検証中                  : libXpm-3.5.12-1.amzn2.0.2.x86_64              21/21 

インストール:
  nginx.x86_64 1:1.18.0-1.amzn2.0.2                                             

依存性関連をインストールしました:
  dejavu-fonts-common.noarch 0:2.33-6.amzn2                                     
  dejavu-sans-fonts.noarch 0:2.33-6.amzn2                                       
  fontconfig.x86_64 0:2.13.0-4.3.amzn2                                          
  fontpackages-filesystem.noarch 0:1.44-8.amzn2                                 
  gd.x86_64 0:2.0.35-27.amzn2                                                   
  gperftools-libs.x86_64 0:2.6.1-1.amzn2                                        
  libX11.x86_64 0:1.6.7-3.amzn2                                                 
  libX11-common.noarch 0:1.6.7-3.amzn2                                          
  libXau.x86_64 0:1.0.8-2.1.amzn2.0.2                                           
  libXpm.x86_64 0:3.5.12-1.amzn2.0.2                                            
  libxcb.x86_64 0:1.12-1.amzn2.0.2                                              
  libxslt.x86_64 0:1.1.28-6.amzn2                                               
  nginx-all-modules.noarch 1:1.18.0-1.amzn2.0.2                                 
  nginx-filesystem.noarch 1:1.18.0-1.amzn2.0.2                                  
  nginx-mod-http-geoip.x86_64 1:1.18.0-1.amzn2.0.2                              
  nginx-mod-http-image-filter.x86_64 1:1.18.0-1.amzn2.0.2                       
  nginx-mod-http-perl.x86_64 1:1.18.0-1.amzn2.0.2                               
  nginx-mod-http-xslt-filter.x86_64 1:1.18.0-1.amzn2.0.2                        
  nginx-mod-mail.x86_64 1:1.18.0-1.amzn2.0.2                                    
  nginx-mod-stream.x86_64 1:1.18.0-1.amzn2.0.2                                  

完了しました!

Nginx Webサーバーの起動

コンソールからバージョン確認し、手動で起動

$ nginx -V
nginx version: nginx/1.18.0
built by gcc 7.3.1 20180712 (Red Hat 7.3.1-10) (GCC) 
built with OpenSSL 1.0.2k-fips  26 Jan 2017
TLS SNI support enabled
configure arguments: --prefix=/usr/share/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib64/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --http-client-body-temp-path=/var/lib/nginx/tmp/client_body --http-proxy-temp-path=/var/lib/nginx/tmp/proxy --http-fastcgi-temp-path=/var/lib/nginx/tmp/fastcgi --http-uwsgi-temp-path=/var/lib/nginx/tmp/uwsgi --http-scgi-temp-path=/var/lib/nginx/tmp/scgi --pid-path=/run/nginx.pid --lock-path=/run/lock/subsys/nginx --user=nginx --group=nginx --with-compat --with-file-aio --with-ipv6 --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-stream_ssl_preread_module --with-http_addition_module --with-http_xslt_module=dynamic --with-http_image_filter_module=dynamic --with-http_geoip_module=dynamic --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_degradation_module --with-http_slice_module --with-http_stub_status_module --with-http_perl_module=dynamic --with-http_auth_request_module --with-mail=dynamic --with-mail_ssl_module --with-pcre --with-pcre-jit --with-stream=dynamic --with-stream_ssl_module --with-google_perftools_module --with-debug --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic' --with-ld-opt='-Wl,-z,relro -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -Wl,-E'

$ sudo systemctl start nginx
$ sudo systemctl -l
UNIT                                                          LOAD   ACTIVE SUB 
(略)
network.service                                               loaded active runn
nginx.service                                                 loaded active runn
(略)

Webサーバー用ポートの開放とWebアクセス開通確認

このあとEC2コンソール画面に戻り、「ステップ 6: セキュリティグループの設定」で、ポート22以外にポート80を追加設定してやり、HTTP用ポートを開く必要あり。こちらもSSH同様、まずは自分のPCからのアクセス用に開放
AWS_InstanceSecurityGpSetting80 copy.png

これでようやくHTTPサーバーNginxにアクセスが成功し、ウェルカム画面を表示させることができた。
NginxWelcome.png

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