nginx 启动时报错Starting nginx (via systemctl): nginx.servic
发布时间:2020-12-13 17:55:28 所属栏目:Linux 来源:网络整理
导读:报错提示: 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. 问题出现原因: 创建配置文件是在
报错提示: 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. 问题出现原因: 创建配置文件是在/etc/nginx/conf.d这个目录系下,文件名是:city.conf,使用/etc/init.d/nginx reload 命令时提示的错误 配置文件内容: 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; ????????}
解答经过: ? ? ? ? 网上说这种错误一般都是目录不存在或者权限不足,所以直接执行下面两条命令即可,结果发现根本行不通。 [root@typecodes?~]#?cd?/var/tmp/ [root@typecodes?~]#?mkdir?-p?/var/tmp/nginx/{client,proxy,fastcgi,uwsgi,scgi} 最终解决办法: ? ? ? ? 1. 使用以下命令,得到错误提示如下: $?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:4Aug?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=1Aug?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) ? ? ? ? 2. 根据错误提示发现是access_log 后面多了一个main错误。手动删除配置文件中main,解决了该问题 反思: ? ? ? ? 多看英文,多看错误提示 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |