Nginx尝试登录到/var/logs而不是/var/log? [英] Nginx trying to log to /var/logs instead of /var/log?

查看:105
本文介绍了Nginx尝试登录到/var/logs而不是/var/log?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用nginx -t测试我的nginx配置时,我注意到了,它给了我一个警告:

I noticed when I test my nginx config using nginx -t, it gives me a warning:

nginx: [alert] could not open error log file: open() "/var/logs/nginx/error.log" failed (2: No such file or directory)

这很有意义,因为nginx的日志路径实际上设置为/var/log/nginx/而不是/var/logs/nginx.

Which makes sense, since the log path for nginx is actually set up to be /var/log/nginx/ not /var/logs/nginx.

我扫描了整个nginx config目录,并且没有任何引用/var/logs的内容.我不知道该日志位置可以写在哪里?

I scanned the entire nginx config directory and there is nothing there referencing /var/logs. I'm at a loss as to where this log location could be written?

推荐答案

在终端中运行此命令(注意:大写V):

Run this command in a terminal (note: capital V):

nginx -V

您在那里找到/var/logs吗?您的nginx可能会使用该默认文件位置进行编译.

Do you find /var/logs there? Your nginx might be compiled with that default file location.

[ EDIT ]

我想您的某些服务器块没有"error_log"指令.因此,nginx会尝试使用默认值.请注意,默认情况下,error_log始终处于打开状态.

I guess that some of your server blocks don't have the "error_log" directive. So nginx tries the default one for them. Note that by default the error_log is always on.

要解决此问题,您可以在 main 块(顶层)上添加此行,以便所有子块都可以继承该设置:

To fix this issue, you can add this line on the main block (the top level) such that all child blocks can inherit the setting:

error_log /var/log/nginx/error.log;

这篇关于Nginx尝试登录到/var/logs而不是/var/log?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆