菜单 学习猿地 - LMONKEY

VIP

开通学习猿地VIP

尊享10项VIP特权 持续新增

知识通关挑战

打卡带练!告别无效练习

接私单赚外块

VIP优先接,累计金额超百万

学习猿地私房课免费学

大厂实战课仅对VIP开放

你的一对一导师

每月可免费咨询大牛30次

领取更多软件工程师实用特权

入驻
429
0

(03)Nginx将配置文件default.conf重命名后报Job for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journalctl -xe" for details.解决方案

原创
05/13 14:22
阅读数 58793

  今天将Nginx的配置文件 default.conf 重命名为 access_mod.conf 执行重启动命令:

nginx -s reload -c /etc/nginx/nginx.conf

  然后报错:Job for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journalctl -xe" for details.

  因为是重命名,没有修改文件内容,配置语法肯定不会出错,按照提示执行:

systemctl status nginx.service

  提示:

  ● nginx.service - nginx - high performance web server
  Loaded: loaded (/usr/lib/systemd/system/nginx.service; disabled; vendor preset: disabled)
  Active: failed (Result: exit-code) since 日 2020-05-03 22:02:03 CST; 1min 8s ago
  Docs: http://nginx.org/en/docs/
  Process: 7899 ExecStart=/usr/sbin/nginx -c /etc/nginx/nginx.conf (code=exited, status=1/FAILURE)

  5月 03 22:02:03 localhost.localdomain systemd[1]: Starting nginx - high performance web server...
  5月 03 22:02:03 localhost.localdomain nginx[7899]: nginx: [emerg] open() "/etc/nginx/conf.d/access_mod.conf" failed (13: Permission denied) in   /etc/nginx/nginx.conf:31
  5月 03 22:02:03 localhost.localdomain systemd[1]: nginx.service: control process exited, code=exited status=1
  5月 03 22:02:03 localhost.localdomain systemd[1]: Failed to start nginx - high performance web server.
  5月 03 22:02:03 localhost.localdomain systemd[1]: Unit nginx.service entered failed state.
  5月 03 22:02:03 localhost.localdomain systemd[1]: nginx.service failed.

  貌似是权限问题,但是查看了一下之前的 default.conf 和 access_mod.conf权限一致啊,经过一番查找,发现一下解决方法:

  依次执行:

sudo nginx -c /etc/nginx/nginx.conf
sudo nginx -s reload

  启动成功了!奇怪的是以后使用

nginx -s reload -c /etc/nginx/nginx.conf

  依然能启动成功。。。我一直用的是root用户,是不是root用户与sudo之间有啥事。。。

 

发表评论

0/200
429 点赞
0 评论
收藏