侧边栏壁纸
博主头像
落叶人生博主等级

走进秋风,寻找秋天的落叶

  • 累计撰写 130562 篇文章
  • 累计创建 28 个标签
  • 累计收到 9 条评论
标签搜索

目 录CONTENT

文章目录

打开Nginx的debug选项

2023-11-08 星期三 / 0 评论 / 0 点赞 / 58 阅读 / 5356 字

通常情况下,Nginx 的错误日志级别是 error,对于Nginx 用户来说,将日志设置为info级别就足够用了。对于比较复杂的情况,需要看到更详细的 debug 级别的日志,如果只是把error_

通常情况下,Nginx 的错误日志级别是 error,对于Nginx 用户来说,将日志设置为info级别就足够用了。对于比较复杂的情况,需要看到更详细的 debug 级别的日志,如果只是把error_log级别设置为debug,Nginx 记录下来的还是info级别以上的信息。只有激活 Nginx的 debug日志才能得到 debug级别的日志信息。下面记录添加debug错误日志的过程。

#查看当前编译选项

[root@username sbin]# ./nginx -Vnginx version: nginx/1.10.3built by gcc 4.8.2 20140120 (Red Hat 4.8.2-16) (GCC) configure arguments: --prefix=/deploy/nginx

#上传Nginx原生文件

scp /Users/username/Downloads/nginx-1.12.0.tar.gz dfecmes/[email protected]:/software

#解压

tar -xzvf nginx-1.12.0.tar.gzcd nginx-1.12.0

#设置编译选项

./configure --prefix=/software/nginx-debug --with-debug

执行以上命令时出现如下错误:

./configure: error: the HTTP rewrite module requires the PCRE library.You can either disable the module by using --without-http_rewrite_moduleoption, or install the PCRE library into the system, or build the PCRE librarystatically from the source with nginx by using --with-pcre=<path> option.

解决办法,安装pcre-devel:

yum -y install pcre-devel

结果如下:

[root@test1 software]# yum -y install pcre-devel已加载插件:fastestmirror, langpacksRepodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fastbase                                                                                                                                                                                        | 3.6 kB  00:00:00     extras                                                                                                                                                                                      | 3.4 kB  00:00:00     updates                                                                                                                                                                                     | 3.4 kB  00:00:00     (1/2): extras/7/x86_64/primary_db                                                                                                                                                           | 167 kB  00:00:00     (2/2): updates/7/x86_64/primary_db                                                                                                                                                          | 5.6 MB  00:00:02     Loading mirror speeds from cached hostfile * base: mirrors.btte.net * extras: mirrors.neusoft.edu.cn * updates: mirrors.neusoft.edu.cn正在解决依赖关系--> 正在检查事务---> 软件包 pcre-devel.x86_64.0.8.32-15.el7_2.1 将被安装--> 解决依赖关系完成依赖关系解决=================================================================================================================================================================================================================== Package                                             架构                                            版本                                                      源                                             大小===================================================================================================================================================================================================================正在安装: pcre-devel                                          x86_64                                          8.32-15.el7_2.1                                           base                                          479 k事务概要===================================================================================================================================================================================================================安装  1 软件包总下载量:479 k安装大小:1.4 MDownloading packages:pcre-devel-8.32-15.el7_2.1.x86_64.rpm                                                                                                                                                       | 479 kB  00:00:00     Running transaction checkRunning transaction testTransaction test succeededRunning transaction  正在安装    : pcre-devel-8.32-15.el7_2.1.x86_64                                                                                                                                                              1/1   验证中      : pcre-devel-8.32-15.el7_2.1.x86_64                                                                                                                                                              1/1 已安装:  pcre-devel.x86_64 0:8.32-15.el7_2.1                                                                                                                                                                              完毕!

#编译源代码并安装

makemake install

然后可以通过 error_log 指令设置 debug 级别:

error_log /path/to/log debug;

广告 广告

评论区