nginx version: nginx/1.21.0
Usage: nginx [-?hvVtTq] [-s signal] [-p prefix]
[-e filename] [-c filename] [-g directives]
Options:
-?,-h : this help
-v : show version and exit
-V : show version and configure options then exit
-t : test configuration and exit
-T : test configuration, dump it and exit
-q : suppress non-error messages during configuration testing
-s signal : send signal to a master process: stop, quit, reopen, reload
-p prefix : set prefix path (default: /opt/homebrew/Cellar/nginx/1.21.0/)
-e filename : set error log file (default: /opt/homebrew/var/log/nginx/error.log)
-c filename : set configuration file (default: /opt/homebrew/etc/nginx/nginx.conf)
-g directives : set global directives out of configuration file
然后,您可以找到配置和日志文件的一些默认路径,在本例中:
/opt/homebrew/log/nginx/error.log
For Mac OS users, you can type nginx -help in your terminal.
nginx version: nginx/1.21.0
Usage: nginx [-?hvVtTq] [-s signal] [-p prefix]
[-e filename] [-c filename] [-g directives]
Options:
-?,-h : this help
-v : show version and exit
-V : show version and configure options then exit
-t : test configuration and exit
-T : test configuration, dump it and exit
-q : suppress non-error messages during configuration testing
-s signal : send signal to a master process: stop, quit, reopen, reload
-p prefix : set prefix path (default: /opt/homebrew/Cellar/nginx/1.21.0/)
-e filename : set error log file (default: /opt/homebrew/var/log/nginx/error.log)
-c filename : set configuration file (default: /opt/homebrew/etc/nginx/nginx.conf)
-g directives : set global directives out of configuration file
Then, you could find some default path for configuration and log files, in this case:
发布评论
评论(10)
错误存储在 nginx 日志文件中。您可以在 nginx 配置文件的根目录中指定它:
在 Mac OS X 上使用 Homebrew ,默认情况下在以下位置找到日志文件:
Errors are stored in the nginx log file. You can specify it in the root of the nginx configuration file:
On Mac OS X with Homebrew, the log file was found by default at the following location:
我正在寻找不同的解决方案。
默认情况下,在我的系统上设置任何配置之前的错误日志(x86 Arch Linux),被发现于:
I was looking for a different solution.
Error logs, by default, before any configuration is set, on my system (x86 Arch Linux), was found in:
在大多数情况下,您可以使用 lsof(打开文件列表)来查找打开的日志文件,而无需了解配置。
示例:
查找
httpd
的PID(同样的概念也适用于nginx和其他程序):然后使用
lsof
搜索打开的日志文件PID:如果 lsof 没有打印任何内容,即使您希望找到日志文件,也可以使用 sudo 发出相同的命令。
您可以阅读更多内容 此处。
You can use
lsof
(list of open files) in most cases to find open log files without knowing the configuration.Example:
Find the PID of
httpd
(the same concept applies for nginx and other programs):Then search for open log files using
lsof
with the PID:If
lsof
prints nothing, even though you expected the log files to be found, issue the same command usingsudo
.You can read a little more here.
运行此命令,检查错误日志:
Run this command, to check error logs:
我的 ngninx 日志位于此处:
您还可以检查您的
nginx.conf
以查看是否有任何指令转储到自定义日志。运行
nginx -t
找到您的nginx.conf
。Nginx 通常设置在
/usr/local
或/etc/
中。服务器也可以配置为将日志转储到/var/log
。如果您有 nginx 安装的备用位置并且其他所有方法都失败,您可以使用
find
命令来找到您选择的文件。find /usr/ -path "*/nginx/*" -type f -name '*.log'
,其中/usr/
是您要开始搜索的文件夹从。My ngninx logs are located here:
You can also check your
nginx.conf
to see if you have any directives dumping to custom log.run
nginx -t
to locate yournginx.conf
.Nginx is usually set up in
/usr/local
or/etc/
. The server could be configured to dump logs to/var/log
as well.If you have an alternate location for your nginx install and all else fails, you could use the
find
command to locate your file of choice.find /usr/ -path "*/nginx/*" -type f -name '*.log'
, where/usr/
is the folder you wish to start searching from.Linux 服务器上的日志位置:
Logs location on Linux servers:
对于 Mac OS 用户,您可以在终端中输入
nginx -help
。然后,您可以找到配置和日志文件的一些默认路径,在本例中:
For Mac OS users, you can type
nginx -help
in your terminal.Then, you could find some default path for configuration and log files, in this case:
在终端中输入以下命令:
Type this command in the terminal:
在 nginx 配置文件中设置访问日志的位置是一个很好的做法。使用 acces_log /path/ 像这样。
It is a good practice to set where the access log should be in nginx configuring file . Using acces_log /path/ Like this.