AWS EC2でnginxの起動をを試みていますがエラーが出て起動ができません。
背景と経緯を記載します。
Nginx起動への解決策を教えていただけると助かります。
背景:AWS(EC2)にRailsのWebアプリをデプロイ
参考:https://qiita.com/iwaseasahi/items/b28f8b91c4638e2c57fd
Nginxをインストール:
コマンド:$ sudo yum install -y nginx
でインストールできなかったので代わりに以下でインストール
コマンド:$ sudo amazon-linux-extras install nginx1
結果:Installed: nginx.x86_64 1:1.16.1-1.amzn2.0.1
確認:$ nginx -v => nginx version: nginx/1.16.1
Nginxを起動:
コマンド1:$ sudo /etc/init.d/nginx start
結果:command not found
コマンド2:$ sudo service nginx start
結果:Redirecting to /bin/systemctl start nginx.service
Job for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journalctl -xe" for details.
コマンド3:$ sudo /bin/systemctl start nginx.service
結果:The service command supports only basic LSB actions (start, stop, restart, try-restart, reload, force-reload, status). For other actions, please try to use systemctl.
追記:参考のためステータスを出力しました
コマンド:$ sudo systemctl status nginx.service
結果: nginx.service - The nginx HTTP and reverse proxy server
Loaded: loaded (/usr/lib/systemd/system/nginx.service; disabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Thu 2020-01-09 13:04:39 UTC; 21s ago
Process: 31933 ExecStart=/usr/sbin/nginx (code=exited, status=1/FAILURE)
Process: 31929 ExecStartPre=/usr/sbin/nginx -t (code=exited, status=0/SUCCESS)
Process: 31928 ExecStartPre=/usr/bin/rm -f /run/nginx.pid (code=exited, status=0/SUCCESS)
Jan 09 13:04:37 ip-10-0-10-10.ec2.internal nginx[31933]: nginx: [emerg] bind() to [::]...)
Jan 09 13:04:38 ip-10-0-10-10.ec2.internal nginx[31933]: nginx: [emerg] bind() to 0.0....)
Jan 09 13:04:38 ip-10-0-10-10.ec2.internal nginx[31933]: nginx: [emerg] bind() to [::]...)
Jan 09 13:04:38 ip-10-0-10-10.ec2.internal nginx[31933]: nginx: [emerg] bind() to 0.0....)
Jan 09 13:04:38 ip-10-0-10-10.ec2.internal nginx[31933]: nginx: [emerg] bind() to [::]...)
Jan 09 13:04:39 ip-10-0-10-10.ec2.internal nginx[31933]: nginx: [emerg] still could no...)
Jan 09 13:04:39 ip-10-0-10-10.ec2.internal systemd[1]: nginx.service: control process ...1
Jan 09 13:04:39 ip-10-0-10-10.ec2.internal systemd[1]: Failed to start The nginx HTTP ....
Jan 09 13:04:39 ip-10-0-10-10.ec2.internal systemd[1]: Unit nginx.service entered fail....
Jan 09 13:04:39 ip-10-0-10-10.ec2.internal systemd[1]: nginx.service failed.
Hint: Some lines were ellipsized, use -l to show in full.
追記2:コマンドの結果を記載しました。
コマンド1: $ sudo systemctl -l status nginx.service
結果: nginx.service - The nginx HTTP and reverse proxy server
Loaded: loaded (/usr/lib/systemd/system/nginx.service; disabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Thu 2020-01-09 22:30:15 UTC; 19s ago
Process: 1077 ExecStart=/usr/sbin/nginx (code=exited, status=1/FAILURE)
Process: 1074 ExecStartPre=/usr/sbin/nginx -t (code=exited, status=0/SUCCESS)
Process: 1073 ExecStartPre=/usr/bin/rm -f /run/nginx.pid (code=exited, status=0/SUCCESS)
Jan 09 22:30:14 ip-10-0-10-10.ec2.internal nginx[1077]: nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
Jan 09 22:30:14 ip-10-0-10-10.ec2.internal nginx[1077]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
Jan 09 22:30:14 ip-10-0-10-10.ec2.internal nginx[1077]: nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
Jan 09 22:30:15 ip-10-0-10-10.ec2.internal nginx[1077]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
Jan 09 22:30:15 ip-10-0-10-10.ec2.internal nginx[1077]: nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
Jan 09 22:30:15 ip-10-0-10-10.ec2.internal nginx[1077]: nginx: [emerg] still could not bind()
Jan 09 22:30:15 ip-10-0-10-10.ec2.internal systemd[1]: nginx.service: control process exited, code=exited status=1
Jan 09 22:30:15 ip-10-0-10-10.ec2.internal systemd[1]: Failed to start The nginx HTTP and reverse proxy server.
Jan 09 22:30:15 ip-10-0-10-10.ec2.internal systemd[1]: Unit nginx.service entered failed state.
Jan 09 22:30:15 ip-10-0-10-10.ec2.internal systemd[1]: nginx.service failed.
コマンド2: $ sudo nginx -t
結果: nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
回答1件
あなたの回答
tips
プレビュー