質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
nginx

nginixは軽量で高性能なwebサーバーの1つです。BSD-likeライセンスのもとリリースされており、あわせてHTTPサーバ、リバースプロキシ、メールプロキシの機能も備えています。MacOSX、Windows、Linux、上で動作します。

Ruby on Rails

Ruby on Railsは、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

Q&A

1回答

2576閲覧

nginxが起動しない

keisuke.F

総合スコア19

nginx

nginixは軽量で高性能なwebサーバーの1つです。BSD-likeライセンスのもとリリースされており、あわせてHTTPサーバ、リバースプロキシ、メールプロキシの機能も備えています。MacOSX、Windows、Linux、上で動作します。

Ruby on Rails

Ruby on Railsは、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

0グッド

0クリップ

投稿2021/01/11 07:16

編集2021/01/11 07:17

前提・実現したいこと

railsで、デプロイ をしてるのですが、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で確認したものが下記です。

● 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 Mon 2021-01-11 07:05:20 UTC; 7min ago Process: 27782 ExecStartPre=/usr/sbin/nginx -t (code=exited, status=1/FAILURE) Process: 27766 ExecStartPre=/usr/bin/rm -f /run/nginx.pid (code=exited, status=0/SUCCESS) Jan 11 07:05:20 ip-172-31-40-146.ap-northeast-1.compute.internal systemd[1]: Starting The nginx HTTP and reverse proxy server... Jan 11 07:05:20 ip-172-31-40-146.ap-northeast-1.compute.internal nginx[27782]: nginx: the configuration file /etc/nginx/nginx.conf syntax is ok Jan 11 07:05:20 ip-172-31-40-146.ap-northeast-1.compute.internal nginx[27782]: nginx: [emerg] open() "/var/www/buggage-mgt/log/nginx.error.log" failed (2: No such file or directory) Jan 11 07:05:20 ip-172-31-40-146.ap-northeast-1.compute.internal nginx[27782]: nginx: configuration file /etc/nginx/nginx.conf test failed Jan 11 07:05:20 ip-172-31-40-146.ap-northeast-1.compute.internal systemd[1]: nginx.service: control process exited, code=exited status=1 Jan 11 07:05:20 ip-172-31-40-146.ap-northeast-1.compute.internal systemd[1]: Failed to start The nginx HTTP and reverse proxy server. Jan 11 07:05:20 ip-172-31-40-146.ap-northeast-1.compute.internal systemd[1]: Unit nginx.service entered failed state. Jan 11 07:05:20 ip-172-31-40-146.ap-northeast-1.compute.internal systemd[1]: nginx.service failed.

nginx -tで確認したものが下記です.

nginx: [alert] could not open error log file: open() "/var/log/nginx/error.log" failed (13: Permission denied) 2021/01/11 07:14:31 [warn] 27883#0: the "user" directive makes sense only if the master process runs with super-user privileges, ignored in /etc/nginx/nginx.conf:5 nginx: the configuration file /etc/nginx/nginx.conf syntax is ok 2021/01/11 07:14:31 [emerg] 27883#0: open() "/run/nginx.pid" failed (13: Permission denied) nginx: configuration file /etc/nginx/nginx.conf test failed

nginx.error.logは、存在しなかったので、作成してみましたが、変わらなかったです。
その他、気になる箇所があれば、ご教授願いたいです。

よろしくお願いいたします。

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

最後に示されているメッセージのうち、2行が手掛かりを与えてくれています。

nginx: [alert] could not open error log file: open() "/var/log/nginx/error.log" failed (13: Permission denied) 2021/01/11 07:14:31 [emerg] 27883#0: open() "/run/nginx.pid" failed (13: Permission denied)

いずれにも Permission denied と書かれていますね??

これは、それぞれのファイルに設定されているPermissionが誤っており、システムがそれらのファイルを利用できなかったためにエラーが発生した、ということを教えてくれています。

それらのファイルの所有者や権限を変更してみましょう。

どの権限にすべきなのかは一度ご自身で調べてみて、それでもわからなければ、質問文の修正やコメントでまた追加の回答依頼をしていただければと思います。

投稿2021/01/11 08:49

siruku6

総合スコア1382

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

keisuke.F

2021/01/11 09:33

ご回答ありがとうございます。 /var/log/nginx/error.logと、/run/nginx.pidに、下記を実行してみました。 ``` sudo chown -R ec2-user nginx.pid(error.logも) chmod 755 nginx.pid(error.logも) ``` しかし、エラーは変わりませんでした。 また、 sudo nginx -tと、nginx -tでは出てくるエラーが違いました。 nginx -tは、初めの質問のとおりですが、sudo nginx -tだと下記の様になります。 ``` nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: [emerg] open() "/var/www/buggage-mgt/log/nginx.error.log" failed (2: No such file or directory) nginx: configuration file /etc/nginx/nginx.conf test failed ``{
siruku6

2021/01/23 03:00 編集

確信はないのですが、所有者を`nginx`にするとどうなるでしょうか?? $ sudo chown -R nginx nginx.pid (その他のファイルも同様) 私が把握している限りだと、nginx関連のファイルの所有者は`nginx`になっていました
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだベストアンサーが選ばれていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問