Nginx source code (3) Debugging

Source: Internet
Author: User
: This article mainly introduces nginx source code (3) Debugging. For more information about PHP tutorials, see. Next

After nginx is run, a master and three process processes run. to facilitate debugging, you need to modify this configuration.

Change the source code directly here. to make it more convenient, modify the Makefile first.
From the original

clean:    rm -rf Makefile objs

To:

clean:    rm -rf nginx objs/ngx_modules.o objs/src/core*.o objs/src/event/*.o objs/src/event/modules/*.o objs/src/http/*.o objs/src/http/modules/*.o objs/src/http/modules/proxy/*.o objs/src/os/unix/*.o

In this way, the Makefile files will not be all deleted after make clean.

Comment out the daemon and multi-process-related code in core/nginx. c:

/*    if (!ngx_inherited && ccf->daemon) {        if (ngx_daemon(cycle->log) == NGX_ERROR) {            return 1;        }        ngx_daemonized = 1;    }    */

And

printf("[main] to start ngx_single_process_cycle\n");    ///if (ngx_process == NGX_PROCESS_MASTER) {///    ngx_master_process_cycle(cycle, &ctx);///} else {        ngx_single_process_cycle(cycle, &ctx);    ///}

I added a printf on it because nginx runs directly on the console to verify the printing. at the same time, for convenience of subsequent startup, the conf/nginx. change the port number in conf to 8080 and run make again. The output is printed on the console. When the browser accesses http: // localhost: 8080, success is also returned. other log information is output to the file in the logs directory.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.