
AWS Nginxの単体起動確認
sudo amazon-linux-extras install nginx1
Nginxをインストール

nginx -v
インストール確認

sudo systemctl start nginx
Nginxを起動
systemctl status nginx
起動確認

EC2セキュリティーグループのインバウンドルールにポート80を追加

http://パブリック IPv4 アドレス/
へアクセス

成功したらWelcome to Nginx!が出るはずですが、502 Bad Gatewayのエラー

sudo systemctl stop nginx
一旦Nginx停止

netstat -tuln | grep 80
ポート80でリッスンしているプロセスを確認する

sudo systemctl start nginx
Nginxを起動して、
sudo netstat -tuln | grep LISTEN | grep 80
LISTEN状態のTCPソケットのみを表示、その中でもポート80のものを表示

sudo nano /etc/nginx/nginx.conf
でNginx設定ファイルを編集

sudo nginx -t
でテキスト構文チェック

sudo systemctl restart nginx
Nginxを再起動
systemctl status nginx起動確認

いざリベンジ!http://パブリック IPv4 アドレス/
な…もうやだ

sudo nano /etc/nginx/nginx.conf
でNginx設定ファイルを編集見直し

スペル違うやん
なんでsudo nginx -tでokなってたん意味不明
sudo systemctl restart nginx
Nginxを再起動
systemctl status nginx起動確認

いざリベンジのリベンジ!http://パブリック IPv4 アドレス/

やったー!!できた!
次は、unicornとnginxを組み合わせてのrailsアプリケーション動作確認をします。

Thank you!!