修改nginx源码-hello world入门

尝试修改nginx源码,第一步就是修改nginx,打印出hello world,顺便加下自己的名字。操作如下:

1: 去官网下载nginx源码

http://nginx.org/download/

2: 根据配置选项和系统情况生成makefile文件(这一步在修改完代码后是不用再执行的)

./configure --prefix=/usr/local/nginx

3: 根据makefile编译源码(修改代码后make会根据你修改的文件重新编译源码)

make

4: 安装源码

make install

5: 修改nginx探测配置的提示信息

/usr/local/nginx/sbin/nginx  -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful

根据输出搜索源代码:

cd nginx-1.8.0

grep 'syntax is ok' * -r

src/core/ngx_cycle.c:        ngx_log_stderr(0, "nginx: the configuration file %s syntax is ok",

6: 修改源码并重新编译

vim src/core/ngx_cycle.c

        ngx_log_stderr(0, "hello, Lisi make it\nnginx: the configuration file %s syntax is ok",

make && make install 

7: 验证修改代码是否生效

/usr/local/nginx/sbin/nginx  -t
nginx: hello, Lisi make it
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful

 

高手都是阅读代码的一些核心功能进行改善,本人看不懂里面的代码是什么东东。

 

最后附上本人的网络课堂地址,如有兴趣请点击: 实践哥

转载于:https://my.oschina.net/zhuangweihong/blog/733060

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值