nginx环境+编译+调试
# nginx环境:
nginx编译+配置环境 (opens new window)
# 下载
wget http://nginx.org/download/nginx-1.24.0.tar.gz
# 解压
tar -zxvf nginx-1.24.0.tar.gz
# 进入到源码目录
cd nginx-1.24.0/
cp -r contrib/vim/* ~/.vim # vim工具,高亮配置文件
# 查看configure 支持的参数,其中包含指定某些路径、开启某些模块、编译中特殊参数
#./configure --help | more
# 安装nginx必备依赖库
yum -y install gcc pcre pcre-devel zlib zlib-devel openssl openssl-devel
# 进行编译,指定安装目录,没什么报错就是编译成功
./configure --prefix=/nginx --with-debug
make
make install
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
yum install -y pcre pcre-devel
yum install -y zlib zlib-devel
yum install -y openssl openssl-devel
yum install gcc-c++
yum -y install lua*
1
yum install -y wget
[nginx编译报错src/core/ngx_murmurhash.c:37:11: 错误:this statement may fall through -Werror=implicit-fallthrough=] h ^= data[2] (opens new window)
解决/usr/local/nginx/sbin/nginx: error while loading shared libraries: libluajit-5.1.so.2: cannot open
解决无法找到struct crypt_data定义
nginx ‘struct crypt_data’没有名为‘current_salt’的成员 (opens new window)
解决无法找到共享库**libpcre.so.1**
# 调试
- gdb关联进程调试时出现
ptrace: Operation not permitted.
# 设置容器的privileged权限
docker exec --privileged -it build-pg /bin/bash
# 设置允许非PTRACE权限的进程使用ptrace系统调用来追踪其他进程
echo 0 > /proc/sys/kernel/yama/ptrace_scope # 系统和容器的值都要修改
1
2
3
4
2
3
4
- ./configure --prefix=/nginx --with-debug
./objs/Makefile 下修改 增加-g (不确定是否需要)
ps -ef | grep nginx 查看工作线程和主线程(e为显示所有进程,f为全格式显示)
- 为了方便调试,关闭主线程,只有一个工作线程
vim [nginx的安装目录]/conf/nginx.conf
添加master_process off; # 关闭主线程,只有一个工作线程
添加daemon off # 关闭守护进程,前台工作
- b ngx_event.c:ngx_process_events_and_timers
上次更新: 2025/02/21, 14:57:10

