0

Ubuntu上でnginxを起動しようとしていますが、次のエラーメッセージが出てきます。

$ sudo service nginx start

Job for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journalctl -xe" for details.

そこで、「systemctl status nginx.service」を実行しました。
そうしたら、次のメッセージになりました。

$ systemctl status nginx.service
● nginx.service - nginx - high performance web server
   Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: en
abled)
   Active: failed (Result: exit-code) since 水 2018-10-31 09:08:49 JST; 9min ago
     Docs: http://nginx.org/en/docs/
  Process: 19669 ExecStart=/usr/sbin/nginx -c /etc/nginx/nginx.conf (code=exited
, status=1/FAILURE)

10月 31 09:08:47 ubuntu nginx[19669]: nginx: [emerg] bind() to 0.0.0.0:80 failed
 (98: Address already in use)
10月 31 09:08:47 ubuntu nginx[19669]: nginx: [emerg] bind() to 0.0.0.0:80 failed
 (98: Address already in use)
10月 31 09:08:48 ubuntu nginx[19669]: nginx: [emerg] bind() to 0.0.0.0:80 failed
 (98: Address already in use)
10月 31 09:08:48 ubuntu nginx[19669]: nginx: [emerg] bind() to 0.0.0.0:80 failed
 (98: Address already in use)
10月 31 09:08:49 ubuntu nginx[19669]: nginx: [emerg] bind() to 0.0.0.0:80 failed
 (98: Address already in use)
10月 31 09:08:49 ubuntu nginx[19669]: nginx: [emerg] still could not bind()
10月 31 09:08:49 ubuntu systemd[1]: nginx.service: Control process exited, code=
exited status=1
10月 31 09:08:49 ubuntu systemd[1]: Failed to start nginx - high performance web
 server.
10月 31 09:08:49 ubuntu systemd[1]: nginx.service: Unit entered failed state.
10月 31 09:08:49 ubuntu systemd[1]: nginx.service: Failed with result 'exit-code
'.

次に、「journalctl -xe」を実行しました。
そうしたら、次のメッセージになりました。

$ journalctl -xe


    -- Unit nginx.service has begun starting up.
    10月 31 09:08:47 ubuntu nginx[19669]: nginx: [emerg] bind() to 0.0.0.0:80 failed
    10月 31 09:08:47 ubuntu nginx[19669]: nginx: [emerg] bind() to 0.0.0.0:80 failed
    10月 31 09:08:48 ubuntu nginx[19669]: nginx: [emerg] bind() to 0.0.0.0:80 failed
    10月 31 09:08:48 ubuntu nginx[19669]: nginx: [emerg] bind() to 0.0.0.0:80 failed
    10月 31 09:08:49 ubuntu nginx[19669]: nginx: [emerg] bind() to 0.0.0.0:80 failed
    10月 31 09:08:49 ubuntu nginx[19669]: nginx: [emerg] still could not bind()
    10月 31 09:08:49 ubuntu systemd[1]: nginx.service: Control process exited, code=
    10月 31 09:08:49 ubuntu systemd[1]: Failed to start nginx - high performance web
    -- Subject: Unit nginx.service has failed
    -- Defined-By: systemd
    -- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
    -- 
    -- Unit nginx.service has failed.
    -- 
    -- The result is failed.
    10月 31 09:08:49 ubuntu systemd[1]: nginx.service: Unit entered failed state.
    10月 31 09:08:49 ubuntu systemd[1]: nginx.service: Failed with result 'exit-code
    10月 31 09:08:49 ubuntu sudo[19637]: pam_unix(sudo:session): session closed for 
    10月 31 09:09:22 ubuntu wpa_supplicant[2635]: wlp2s0: WPA: Group rekeying comple
    10月 31 09:09:42 ubuntu sudo[19698]:  flicfit : TTY=pts/2 ; PWD=/home/flicfit/fl
    10月 31 09:09:42 ubuntu sudo[19698]: pam_unix(sudo:session): session opened for 

何か設定がおかしいようですが、どこが悪いのか、どうしたらいいのかがわかりません。
何かわかる方、よろしくお願いします。
環境は、次のとおりです。

・ubuntu16.04
・nginx/1.14.0

本件、自己解決しましたので、クローズします。
ご協力、ありがとうございました。

5
  • 設定がおかしいなら、設定ファイルの内容載せないと...解答付かないと思いますよ。
    – 豚吐露
    2018年10月31日 0:09
  • ありがとうございます。本件、80番ポートをすでにバインドしているプロセスが存在していたための問題でした。自己解決しましたので、本件はクローズします。ご協力ありがとうございました。
    – user29110
    2018年10月31日 0:26
  • 1
    http(tcp/80ポート)が既に使われてるようですね。lsof -i:80 を実行して何のプロセスが使用しているか確認できますか?
    – take88
    2018年10月31日 2:16
  • ログメッセージが切れているようにも見えますが、単純に「既にnginxが起動した状態だった = 再起動をかければよかった」ではないでしょうか。
    – cubick
    2018年11月1日 1:56
  • 原因は、他のアプリケーションが80番ポートを使用していたということです。
    – user29110
    2018年11月4日 23:17

1 件の回答 1

1

原因は他のアプリケーションが80番ポートを使用していたということです。
(コメント欄より)

この質問に回答するには、ログインする必要があります。

求めていた回答ではありませんか? のタグが付いた他の質問を参照する。