nginx 启动时报错Starting nginx (via systemctl): nginx.serviceJob
发布时间:2020-05-24 03:49:50 所属栏目:Linux 来源:互联网
导读:nginx 启动时报错Starting nginx (via systemctl): nginx.serviceJob for nginx.service failed 解决方法
|
报错提示: Startingnginx(viasystemctl):nginx.serviceJobfornginx.servicefailedbecausethecontrolprocessexitedwitherrorcode. See"systemctlstatusnginx.service"and"journalctl-xe"fordetails. 问题出现原因: 创建配置文件是在/etc/nginx/conf.d这个目录系下,文件名是:city.conf,使用/etc/init.d/nginx reload 命令时提示的错误 配置文件内容: server{#这个server标识我要配置了
listen80;
server_name192.168.17.129;
access_log/var/log/nginx/access.logmain;
charsetutf-8;
gzipon;
gzip_typestext/plainapplication/x-javascripttext/csstext/javascriptapplication/x-httpd-phpapplication/jsontext/jsonimage/jpegimage/gifimage/pngapplication/octet-stream;
error_page404/404.html;
error_page500502503504/50x.html;
#指定项目路径uwsgi
location/{#这个location就和咱们Django的url(r'^admin/',admin.site.urls),includeuwsgi_params;#导入一个Nginx模块他是用来和uWSGI进行通讯的
uwsgi_connect_timeout30;#设置连接uWSGI超时时间
uwsgi_passunix:/home/script/uwsgi.sock;#指定uwsgi的sock文件所有动态请求就会直接丢给他
}
#指定静态文件路径
location/static/{
alias/home/trunk/static/;
indexindex.htmlindex.htm;
}
解答经过: 网上说这种错误一般都是目录不存在或者权限不足,所以直接执行下面两条命令即可,结果发现根本行不通。 [root@typecodes~]#cd/var/tmp/
[root@typecodes~]#mkdir-p/var/tmp/nginx/{client,proxy,fastcgi,uwsgi,scgi}
最终解决办法: 1. 使用以下命令,得到错误提示如下: $systemctlstatusnginx.service nginx.service-Ahighperformancewebserverandareverseproxyserver Loaded:loaded(/lib/systemd/system/nginx.service;enabled;vendorpreset:enabled) Active:failed(Result:exit-code)sinceTue2017-08-2204:12:48PDT;31minago Process:7030ExecStop=/sbin/start-stop-daemon--quiet--stop--retryQUIT/5--pidfile/run/nginx.pid(code=exited,status=0 Process:6525ExecReload=/usr/sbin/nginx-gdaemonon;master_processon;-sreload(code=exited,status=1/FAILURE) Process:6957ExecStart=/usr/sbin/nginx-gdaemonon;master_processon;(code=exited,status=0/SUCCESS) Process:7174ExecStartPre=/usr/sbin/nginx-t-q-gdaemonon;master_processon;(code=exited,status=1/FAILURE) MainPID:6961(code=exited,status=0/SUCCESS) Aug2204:12:48ubuntusystemd[1]:StartingAhighperformancewebserverandareverseproxyserver... Aug2204:12:48ubuntunginx[7174]:nginx:[emerg]unknownlogformat"main"in/etc/nginx/conf.d/city.conf:4Aug2204:12:48ubuntunginx[7174]:nginx:configurationfile/etc/nginx/nginx.conftestfailed Aug2204:12:48ubuntusystemd[1]:nginx.service:Controlprocessexited,code=exitedstatus=1Aug2204:12:48ubuntusystemd[1]:FailedtostartAhighperformancewebserverandareverseproxyserver. Aug2204:12:48ubuntusystemd[1]:nginx.service:Unitenteredfailedstate. Aug2204:12:48ubuntusystemd[1]:nginx.service:Failedwithresult'exit-code'. lines1-16/16(END) 2. 根据错误提示发现是access_log 后面多了一个main错误。手动删除配置文件中main,解决了该问题 反思: 多看英文,多看错误提示 (编辑:安卓应用网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
