NGINX笔记

2017-05-28  本文已影响0人  橄榄树下的托马斯

作者:刘宾, thomas_liub@hotmail.com
请尊重作者著作权,转载请注明出处,谢谢!


参考

架构

request处理流程

Nginx模块

Core模块,ngx_core_module

main()
    |_ ngx_master_process_cycle()
        |_ ngx_start_worker_processes()
            |_ ngx_worker_process_cycle()
                |_ ngx_worker_process_init()
                |_ main loop
                    |_ ngx_process_events_and_timers()
                        |_ ngx_event_process_posted(ngx_posted_accept_events)
                        |_ ngx_event_process_posted(ngx_posted_events)
                    |_ ngx_reopen_files()
ngx_events_module:
    |_ ngx_event_process_init()
        |_ ngx_event_accept()
        |_ ngx_event_recvmsg()
ngx_http_module:
    |_ ngx_http_block()
        |_ ngx_http_init_phase_handlers()
        |_ ngx_http_optimize_servers()
            |_ ngx_http_init_listening()
                |_ ngx_http_add_listening()
                    |_ ngx_create_listening()
                    |_ ngx_http_init_connection()
                        |_ ngx_http_wait_request_handler()
                            |_ ngx_http_create_request()
                            |_ ngx_http_process_request_line()
                                |_ ngx_http_read_request_header()
                                |_ ngx_http_parse_request_line()
                                |_ ngx_http_process_request()
                                    |_ ngx_http_request_handler()
                                    |_ ngx_http_handler()
                                |_ ngx_http_process_request_headers()

Nginx配置文件

error_page   500 502 503 504  /50x.html;
location / {
    root   /home/jizhao/nginx-book/build/html;
    index  index.html index.htm;
}

编译

  1. 编写config文件
ngx_addon_name=ngx_http_hello_module
HTTP_MODULES="$HTTP_MODULES ngx_http_hello_module"
NGX_ADDON_SRCS="$NGX_ADDON_SRCS $ngx_addon_dir/ngx_http_hello_module.c"
  1. configure
./configure --prefix=/usr/local/nginx --add-module=/home/liub/project/nginx_gateway/src/cy
  1. make build
  2. make install
上一篇 下一篇

猜你喜欢

热点阅读