CentOS 7 Nginx 错误集合

「我的记录,确定有理解错误和理解不透的地方,小白老是有个成长的过程,但愿你们多多指教。」 nginx

「下面的一些错误也只是本身遇到的低级错误,在大神眼里也许都是常识,求指导,^_^」 shell

Nginx 错误集合

1、$ env: /etc/init.d/nginx: 没有那个文件或目录


    这个问题刚开始困惑了我好久,明明文件是存在的啊,脚本也没什么错啊,怎么就是说文件找不到,后面在网看到说是由于文件格式为doc,Linux不能识别,因此,个人作法是把文件内容复制出来,而后把以前的/etc/init.d/nginx删除,用 vi /etc/init.d/nginx再建一个,再把内容复制进去,我是这么解决了。在网上又看到一个理简便的方法:能够经过vim打开该文件,若是能够看到出现 ^M 的字符,就能够肯定是DOS格式的了。那么能够在vim中执行命令 :%s/\r\+$//e ,将其转换成Unix格式便可。 第二种方法没试过,不知道能不能行,我相信应该是能够的。 vim

二、Starting nginx (via systemctl): Warning: Unit file of nginx.service changed on disk, 'systemctl daemon-reload' recommended


        这是一个警告,这个是在我修改/etc/init.d/nginx文件以后出现的,这个问题,直接按它提示的操做:$ systemctl daemon-reload 就能够了。 spa


三、Starting nginx (via systemctl): Job for nginx.service failed. See 'systemctl status nginx.service' and 'journalctl -xn' for details.


        出现这样的提示,通常先执行 $ systemctl status nginx.service  看看下面的具体状况,好比: .net

[root@Leco init.d]# systemctl status nginx.service
nginx.service - LSB: start and stop nginx
   Loaded: loaded (/etc/rc.d/init.d/nginx)
   Active: failed (Result: resources) since 三 2015-06-24 20:21:31 CST; 5min ago
  Process: 18620 ExecStart=/etc/rc.d/init.d/nginx start (code=exited, status=0/SUCCESS)

6月 24 20:21:31 Leco.lan systemd[1]: Starting LSB: start and stop nginx...
6月 24 20:21:31 Leco.lan nginx[18620]: Starting nginx: nginx: [emerg] open() "/var/run/nginx/nginx.pid" failed (2: No such file or directory)
6月 24 20:21:31 Leco.lan nginx[18620]: [  肯定  ]
6月 24 20:21:31 Leco.lan systemd[1]: PID file /var/run/nginx/nginx.pid not readable (yet?) after start.
6月 24 20:21:31 Leco.lan systemd[1]: Failed to start LSB: start and stop nginx.
6月 24 20:21:31 Leco.lan systemd[1]: Unit nginx.service entered failed state.

其实看到这个systemctl这个东西出来了,就能够使用新RHEL 7的启动服务方式了,给个传送门供你们参考下这个方式:http://my.oschina.net/liucao/blog/470458 日志

四、nginx: [emerg] mkdir() "/var/cache/nginx/client" failed (2: No such file or directory)

        这种都属于常见的,$ sudo mkdir -p /var/cache/nginx/client 就能够了,相似的问题都是这样作,可是像/var/run/nginx/nginx.pid这样的进程文件好像不能这样作吧。 code


五、nginx: [alert] could not open error log file: open() "/var/log/nginx/error.log" failed (13: Permission denied) 2015/06/25 13:46:55 [emerg] 4392#0: open() "/var/log/nginx/access.log" failed (13: Permission denied)


        这个一看就是权限问题,切换 $ sudo 或 $ su。你们主要仍是要耐心的把错误日志看完整,不要一出问题就去Google,之前我也有那样的臭毛病,很简单的问题,你们也不会去在网上发,结果找半天也没有网上找到答案,结果回头仔细看看日志,又找到了毛病。 blog




待续…… 进程

相关文章
相关标签/搜索