今更ですが、動かします。
参考ではdnfでインストールしていますが、yumで入れてしまいました。
$ sudo yum install nginx
$ dnf info nginx
Last metadata expiration check: 0:04:00 ago on Tue Mar 18 13:37:18 2025.
Installed Packages
Name : nginx
Epoch : 1
Version : 1.26.3
Release : 1.amzn2023.0.1
Architecture : x86_64
Size : 127 k
Source : nginx-1.26.3-1.amzn2023.0.1.src.rpm
Repository : @System
From repo : amazonlinux
Summary : A high performance web server and reverse proxy server
URL : https://nginx.org
License : BSD-2-Clause
Description : Nginx is a web server and a reverse proxy server for HTTP, SMTP, POP3 and
: IMAP protocols, with a strong focus on high concurrency, performance and low
: memory usage.
※前は、Installedとか表示があった追うな気がするけど、今は・・・
動作状況を確認します。(動いていないはず)
$ sudo systemctl status nginx
○ nginx.service - The nginx HTTP and reverse proxy server
Loaded: loaded (/usr/lib/systemd/system/nginx.service; disabled; preset: disabled)
Active: inactive (dead)
起動します。
$ sudo systemctl start nginx
$ sudo systemctl status nginx
● nginx.service - The nginx HTTP and reverse proxy server
Loaded: loaded (/usr/lib/systemd/system/nginx.service; disabled; preset: disabled)
Active: active (running) since Tue 2025-03-18 13:42:46 JST; 3s ago
Process: 2603 ExecStartPre=/usr/bin/rm -f /run/nginx.pid (code=exited, status=0/SUCCESS)
Process: 2607 ExecStartPre=/usr/sbin/nginx -t (code=exited, status=0/SUCCESS)
Process: 2623 ExecStart=/usr/sbin/nginx (code=exited, status=0/SUCCESS)
Main PID: 2635 (nginx)
Tasks: 2 (limit: 505)
Memory: 4.1M
CPU: 55ms
CGroup: /system.slice/nginx.service
tq2635 "nginx: master process /usr/sbin/nginx"
mq2636 "nginx: worker process"
Mar 18 13:42:46 ip-172-31-44-142.ap-northeast-1.compute.internal systemd[1]: Starting nginx.service - The ngi>
Mar 18 13:42:46 ip-172-31-44-142.ap-northeast-1.compute.internal nginx[2607]: nginx: the configuration file />
Mar 18 13:42:46 ip-172-31-44-142.ap-northeast-1.compute.internal nginx[2607]: nginx: configuration file /etc/>
Mar 18 13:42:46 ip-172-31-44-142.ap-northeast-1.compute.internal systemd[1]: Started nginx.service - The ngin>
リスニングポートを見てみます。
$ netstat -an | grep 80
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN
tcp 0 0 172.31.44.142:33094 169.254.169.254:80 TIME_WAIT
tcp 0 0 172.31.44.142:33076 169.254.169.254:80 TIME_WAIT
tcp 0 0 172.31.44.142:33058 169.254.169.254:80 TIME_WAIT
tcp 0 0 172.31.44.142:33038 169.254.169.254:80 TIME_WAIT
tcp6 0 0 :::80 :::* LISTEN
udp6 0 0 fe80::46f:cdff:fed7:546 :::*
unix 2 [ ACC ] STREAM LISTENING 15800 /run/acpid.socket
unix 2 [ ACC ] STREAM LISTENING 15801 /run/dbus/system_bus_socket
unix 2 [ ACC ] STREAM LISTENING 15804 /run/.heim_org.h5l.kcm-socket
unix 3 [ ] STREAM CONNECTED 15880
unix 3 [ ] STREAM CONNECTED 15803
80/tcpでLISTENしているようです。
マネージメントコンソールでインバウンドの80/tcpを開けます。
(とりあえず自宅のPublic IPからだけ許可します)
ブラウザでアクセスしてみます。

と表示されました。OKです。
confファイルのrootを確認します。
$ cat /etc/nginx/nginx.conf | grep root
root /usr/share/nginx/html;
# root /usr/share/nginx/html;
ここにファイルを置けばいろいろできますね。(staticですが)
あ、LISTENポートは8081にでもしておきましょうか
$ cat /etc/nginx/nginx.conf | grep 80
listen 80;
listen [::]:80;
sudo nanoで編集します。
サービスを再起動
$ sudo systemctl restart nginx
※nginxを再起動せずに設定を反映する $ sudo nginx -s reload なんてのもあるのね。
ブラウザでアクセス確認します。
http://***hogehoge***.amazonaws.com:8081
80での確認と同じものが表示されました。OKです。
自動起動を有効にします。(何気にはじめてやったかも・・何かファイルを作成してenableにするのかな)
$ sudo systemctl enable nginx
Created symlink /etc/systemd/system/multi-user.target.wants/nginx.service →/usr/lib/systemd/system/nginx.service.
$ systemctl is-enabled nginx
enabled