
我之前已经阅读过nginx的源代码,甚至对其进行了更改. 但是,回想起来,我几乎不记得任何事情,
我只记得回调和异步无处不在,而且我的vim + ctags很难索引.
几乎没有任何收获,因为当时打开了代码,而我完全不了解背景和设计思想. 我只知道那是什么.
现在,准备好并再次学习.
在简单的时候,此准备工作分为两个步骤:
1. 掌握HTTP和https的常识. (应该掌握它,否则没有理由阅读nginx代码)
2. 从上至下阅读此页面. (我当然跳起来阅读)

作者: classic_tong
详细信息如下:
nginx官方网站提供的源代码位于以下位置:
github上有一个镜子:
两步,配置然后制作
[root@T9 nginx.git]# ls
auto conf contrib docs Makefile misc objs src
顶级目录如上,configure脚本位于auto下nginx怎么读,但是必须在顶级目录中运行. . 如下:

./auto/configure --prefix=/root/OUTPUT_nginx/ \ --with-http_ssl_module \ --with-http_v2_module \ --with-http_gunzip_module \ --with-stream \ --with-stream_ssl_module \ --with-debug
然后,进行安装,进行安装:
[root@T9 nginx.git]# ll /root/OUTPUT_nginx/ total 4 drwx------ 2 nobody root 6 Sep 9 11:29 client_body_temp drwxr-xr-x 2 root root 4096 Sep 11 11:58 conf drwx------ 2 nobody root 6 Sep 9 11:29 fastcgi_temp drwxr-xr-x 2 root root 40 Sep 9 11:20 html drwxr-xr-x 2 root root 58 Sep 9 16:03 logs drwx------ 2 nobody root 6 Sep 9 11:29 proxy_temp drwxr-xr-x 2 root root 36 Sep 9 16:02 sbin drwx------ 2 nobody root 6 Sep 9 11:29 scgi_temp drwx------ 2 nobody root 6 Sep 9 11:29 uwsgi_temp
(1)
直接运行二进制文件. /sbin/nginx将驱动nginx的守护进程. 大师的几个工作流程:
[root@T9 OUTPUT_nginx]# ps -ef |grep nginx root 9595 1 0 Sep09 ? 00:00:00 nginx: master process ./nginx nobody 9596 9595 0 Sep09 ? 00:00:00 nginx: worker process
使用-s参数可用于不同的守护程序交互. 例如,-s reload可以重新加载配置.

(2)最简单的配置
进行简单的配置,运行并使用它:
[root@T9 OUTPUT_nginx]# cat conf/nginx.conf events { } http { server { location / { root /data/www; } location /images/ { root /data; } } } [root@T9 OUTPUT_nginx]# tree /data/ /data/ ├── images │ └── 1.png └── www └── 1.html
在此基础上,通过以下文档,了解最基本的概念:
通过文档完成其他场景的配置实验:
如何配置https服务器:
如何配置负载均衡:

nginx处理请求的一般过程:
nginx处理流的一般过程:
必须详细阅读,不能跳过:
非常好,非常有益. 说到思想和原因nginx怎么读,请务必阅读. (包括为什么所有这些都是异步和回调的)
必须详细阅读,不能跳过:
读读读
代码实际上并不那么容易阅读. 为了提高效率,这本书非常好:

tengine团队写的另一本书,我没看过,浏览目录也不错.
第三方模块列表:
本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/ruanjian/article-190384-1.html