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

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

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

Unicornは、汎用のRackアプリケーションサーバ。RackとWebサーバーの機能を併せ持ちます。レスポンス処理や、Nginx単体がRackの機能をサポートしていない事から、一般的にはNginx+Unicorn+Railsの構成を取って用います。

nginx

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

Q&A

解決済

1回答

1035閲覧

Nginxが起動できない

decatail

総合スコア41

unicorn

Unicornは、汎用のRackアプリケーションサーバ。RackとWebサーバーの機能を併せ持ちます。レスポンス処理や、Nginx単体がRackの機能をサポートしていない事から、一般的にはNginx+Unicorn+Railsの構成を取って用います。

nginx

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

0グッド

0クリップ

投稿2019/07/22 14:37

編集2019/07/22 14:53

前提・実現したいこと

Ubuntu18.04です。Nginxを入れて、Unicornを入れていわゆるWeb三層なるものにしたいと思っていますが、肝心のNginxが起動しません。Unicornを入れる時にNginx.confをいじったので、これが原因なのかもしれませんが、超絶初心者なので下記を読んでも分かりません。何が理由で起動しないと考えられるでしょうか。

発生している問題・エラーメッセージ

vpsuser@ipaddress:~$ nginx -v nginx version: nginx/1.14.0 (Ubuntu) vpsuser@ipaddress:~$ journalctl -u nginx Hint: You are currently not seeing messages from other users and the system. Users in groups 'adm', 'systemd-journal' can see all messages. Pass -q to turn off this notice. -- Logs begin at Sun 2019-07-07 14:14:00 JST, end at Mon 2019-07-22 23:20:30 JST. -- -- No entries -- vpsuser@ipaddress:~$ systemctl status nginx.service ● nginx.service - A high performance web server and a reverse proxy server Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled) Active: failed (Result: exit-code) since Mon 2019-07-22 23:22:18 JST; 1min 54s ago Docs: man:nginx(8) Process: 1516 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=1/FAILURE) vpsuser@ipaddress:~$ 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.

該当のソースコード

nginx.conf

user www-data; worker_processes auto; pid /run/nginx.pid; include /etc/nginx/modules-enabled/*.conf; events { worker_connections 768; # multi_accept on; } http { ## # Basic Settings ## sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; types_hash_max_size 2048; # server_tokens off; # server_names_hash_bucket_size 64; # server_name_in_redirect off; include /etc/nginx/mime.types; default_type application/octet-stream; ## # SSL Settings ## ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE ssl_prefer_server_ciphers on; ## # Logging Settings ## access_log /var/log/nginx/access.log; error_log /var/log/nginx/error.log; ## # Gzip Settings ## gzip on; gzip_vary on; # gzip_proxied any; # gzip_comp_level 6; # gzip_buffers 16 8k; # gzip_http_version 1.1; gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/\ javascript; ## # Virtual Host Configs ## include /etc/nginx/conf.d/*.conf; include /etc/nginx/sites-enabled/*; upstream unicorn_server { server unix:/var/www/html/tmp/sockets/unicorn.sock; fail_timeout=0; } server { # Sinatraのpublicディレクトリの絶対パスを指定します root /var/www/html/public; # リクエストが通るポート番号を指定します listen 80; # クライアントからのリクエストの最大値を設定します client_max_body_size 4G; # サーバーはこの時間を過ぎたら接続を閉じます keepalive_timeout 5; location / { try_files $uri @app; } location @app { proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_redirect off; # pass to the upstream unicorn server mentioned above proxy_pass http://unicorn_server; } }

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

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

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

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

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

guest

回答1

0

ベストアンサー

ぱっと見、 nginx.conf に } が足りてないですね。
最後に } を追加してみてはいかがでしょうか。
解決しなければ /usr/sbin/nginx -t の結果をお願いします。

投稿2019/07/22 14:56

scsi

総合スコア2840

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

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

decatail

2019/07/22 16:36

コメントありがとうございます。確かに、}が足りないですね。追加した後、「/usr/sbin/nginx -t」とすると「nginx: [alert] could not open error log file: open() "/var/log/nginx/error.log" failed (13: Permission denied) 2019/07/23 01:25:03 [warn] 2383#2383: the "user" directive makes sense only if the master process runs with super-user privileges, ignored in /etc/nginx/nginx.conf:1」とでました。 エラー文にsuper-userの文字が見えたので、「sudo /usr/sbin/nginx -t」すると、 「nginx: [emerg] unknown directive "fail_timeout=0" in /etc/nginx/nginx.conf:66 nginx: configuration file /etc/nginx/nginx.conf test failed」とでました。 nginx.confを編集し、「fail_timeout=0」の行を削除した後、「sudo /usr/sbin/nginx -t」すると、 「nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: configuration file /etc/nginx/nginx.conf test is successful」となり、 「sudo service nginx start」したのちipアドレスをブラウザに打ち込むと「Welcome to nginx!」が出ました。大変ありがとうございます。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

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

ただいまの回答率
85.48%

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

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

質問する

関連した質問