运行sudo service nginx restart,报错* Restarting nginx nginx[fail],启动不了nginx,启动nginx报错

女爷i 2023-06-12 14:29 142阅读 0赞
  1. //运行sudo service nginx restart报错
  2. root@iZm5e3iekfi2rh6udbikaZ:/etc# sudo service nginx restart
  3. * Restarting nginx nginx [fail]
  4. //运行sudo service nginx start没有返回消息
  5. root@iZm5e3iekfi2rh6udbikaZ:/etc# sudo service nginx start
  6. //查看nginx进程,也没有响应的nginx进程
  7. root@iZm5e3iekfi2rh6udbikaZ:/etc# ps -axu | grep nginx
  8. root 17194 0.0 0.0 11760 2260 pts/4 S+ 10:41 0:00 grep --color=auto nginx

解决的方法就是查看当前nginx是因为什么报错

  1. //输入sudo nginx -t,查看错误原因
  2. root@iZm5e3iekfi2rh6udbikaZ:/etc/nginx/conf.d# sudo nginx -t
  3. //返回报错原因,我的错误原因是因为family1.conf文件的第22行少了一个";" 或者 "}"
  4. nginx: [emerg] unexpected end of file, expecting ";" or "}" in /etc/nginx/conf.d/family1.conf:22
  5. nginx: configuration file /etc/nginx/nginx.conf test failed

根据返回的错误原因修改了之后,再次运行sudo nginx -t,现在已经正确了

  1. root@iZm5e3iekfi2rh6udbikaZ:/etc/nginx/conf.d# sudo nginx -t
  2. //返回正确的信息
  3. nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
  4. nginx: configuration file /etc/nginx/nginx.conf test is successful

再次启动nginx

  1. //运行sudo service nginx start
  2. root@iZm5e3iekfi2rh6udbikaZ:/etc/nginx/conf.d# sudo service nginx start
  3. //查看nginx进程,可以看到nginx的进程,现在启动成功了~
  4. root@iZm5e3iekfi2rh6udbikaZ:/etc/nginx/conf.d# ps -axu | grep nginx
  5. root 17374 0.0 0.0 77932 2772 ? Ss 11:00 0:00 nginx: master process /usr/sbin/nginx
  6. root 17375 0.0 0.0 78280 3324 ? S 11:00 0:00 nginx: worker process
  7. root 17376 0.0 0.0 78280 3324 ? S 11:00 0:00 nginx: worker process
  8. root 17377 0.0 0.0 78280 3324 ? S 11:00 0:00 nginx: worker process
  9. root 17378 0.0 0.0 78280 3324 ? S 11:00 0:00 nginx: worker process
  10. root 17380 0.0 0.0 11760 2164 pts/4 S+ 11:00 0:00 grep --color=auto nginx

发表评论

表情:
评论列表 (有 0 条评论,142人围观)

还没有评论,来说两句吧...

相关阅读