1. 软件工具
openssl 加密解密库
pcre 正则库
zlib 压缩库
2. 生成makefile文件和obj目录
- 指定三个库的路径开启nginx大部分的功能
./configure --prefix=/usr/local/nginx --with-http_realip_module --with-http_addition_module --with-http_gzip_static_module --with-http_secure_link_module --with-http_stub_status_module --with-stream --with-pcre=/root/public/nginx/pcre-8.39 --with-zlib=/root/public/nginx/zlib-1.2.11 --with-openssl=/root/public/nginx/openssl-1.1.1g
- 此时nginx目录生成了obj目录,修改obj目录下的Makefile
vim Makefile
修改CFLAGS变量 ‘-g’ 和 ‘-O0’加上生成符合表和禁用优化。(如果有忽略)
- 返回nginx目录直接make&make install,(如果没有root权限加上root权限’sudo make’)
3. gdb调试nginx
- 修改配置文件不使用守护进程,启用单进程模式。(简化调试工作)
master_process off;
daemon off;
- 进入obj目录,启动调试
cd obj
gdb nginx
在gdb中输入main函数的参数
set args -c conf/tem.conf #启动时nginx会加上前缀/usr/local/nginx/
下断点,然后run
例如:b main; r;