linux - 配置nginx文件时启动报错nginx.serviceJob for nginx.service failed

查看:1276
本文介绍了linux - 配置nginx文件时启动报错nginx.serviceJob for nginx.service failed的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问 题

环境:ubuntu 16.04
nginx 最新版本

新手第一次搭建
问题:

在/etc/nginx/conf.d这个文件下 没有默认配置文件
我创建配置文件是在/etc/nginx/conf.d这个目录系下,文件名是:city.conf

server {   # 这个server标识我要配置了
        listen 80;
        server_name 192.168.17.129 ;
        access_log  /var/log/nginx/access.log  main;
        charset  utf-8;
        gzip on;
        gzip_types text/plain application/x-javascript text/css text/javascript application/x-httpd-php application/json text/json image/jpeg image/gif image/png application/octet-stream;

        error_page  404           /404.html;
        error_page   500 502 503 504  /50x.html;

        # 指定项目路径uwsgi
        location / {        # 这个location就和咱们Django的url(r'^admin/', admin.site.urls),
            include uwsgi_params;  # 导入一个Nginx模块他是用来和uWSGI进行通讯的
            uwsgi_connect_timeout 30;  # 设置连接uWSGI超时时间
            uwsgi_pass unix:/home/script/uwsgi.sock;  # 指定uwsgi的sock文件所有动态请求就会直接丢给他
        }

        # 指定静态文件路径
        location /static/ {
            alias  /home/trunk/static/;
            index  index.html index.htm;
        }

提示错误:
Starting nginx (via systemctl): nginx.serviceJob for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journalctl -xe" for details.

网上说这种错误一般都是目录不存在或者权限不足,所以直接执行下面两条命令即可。

[root@typecodes ~]# cd /var/tmp/

[root@typecodes ~]# mkdir -p /var/tmp/nginx/{client,proxy,fastcgi,uwsgi,scgi}

我按照这两个提示做了 没有反应

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 Tue 2017-08-22 04:12:48 PDT; 31min ago
  Process: 7030 ExecStop=/sbin/start-stop-daemon --quiet --stop --retry QUIT/5 --pidfile /run/nginx.pid (code=exited, status=0
  Process: 6525 ExecReload=/usr/sbin/nginx -g daemon on; master_process on; -s reload (code=exited, status=1/FAILURE)
  Process: 6957 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
  Process: 7174 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=1/FAILURE)
 Main PID: 6961 (code=exited, status=0/SUCCESS)

Aug 22 04:12:48 ubuntu systemd[1]: Starting A high performance web server and a reverse proxy server...
Aug 22 04:12:48 ubuntu nginx[7174]: nginx: [emerg] unknown log format "main" in /etc/nginx/conf.d/city.conf:4
Aug 22 04:12:48 ubuntu nginx[7174]: nginx: configuration file /etc/nginx/nginx.conf test failed
Aug 22 04:12:48 ubuntu systemd[1]: nginx.service: Control process exited, code=exited status=1
Aug 22 04:12:48 ubuntu systemd[1]: Failed to start A high performance web server and a reverse proxy server.
Aug 22 04:12:48 ubuntu systemd[1]: nginx.service: Unit entered failed state.
Aug 22 04:12:48 ubuntu systemd[1]: nginx.service: Failed with result 'exit-code'.
lines 1-16/16 (END)

解决方案

systemctl status nginx.service可以看到具体的错误是什么

这篇关于linux - 配置nginx文件时启动报错nginx.serviceJob for nginx.service failed的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆