Reading and practice of "deep understanding Nginx" (i) Nginx installation configuration and HelloWorld

Source: Internet
Author: User
Tags config data structures linux

Recently read Tao's "In-depth understanding of Nginx: module Development and Architecture Analysis", one is to follow Daniel practice reading and write open source code, the second is to learn nginx excellent architecture design, three is to find a point in-depth Linux network programming details. Houtie in his "STL Source Analysis" in the preface said, "Tracking first-class works and the absorption of nutrients, far more than their own closed the door to write a three-stream works, much higher value." I personally like the "in-depth understanding of the Nginx" this book, it explains a very comprehensive, relevant knowledge will be introduced, the overall context is more clear. It just involves a lot of things, and sometimes I wish that paper documents can also be a hyperlink to the use and definition of the structure and functions like online LXR, so it's not too troublesome to jump back and forth. The end of the paper to feel shallow, never know this matter to preach, reading when the nature of the actual hands. This series of blog posts is a record of the process of carding and hands-on learning. However, although hope into the "series", limited to time and energy, as well as the nginx just started, I can not guarantee when the next article will be written well, please understand.

In addition, the original book on the actual hands-on experience of some of the details of the issue has been mentioned, I will not repeat. If no special hints and instructions, the code is the original book code.

I. Installation and configuration

First you need to install the software that you want to use or may use Nginx: GCC, Pcre, Zlib, OpenSSL. Because the original book using Yum direct installation, I am too lazy in the old version (10.04) of the Ubuntu under toss and install package, so directly engaged in a Fedora19 virtual machine can be directly used yum. Although it looks very troublesome, in fact, but also under the ISO image, with Vim, to do a file sharing, familiar. In addition, it should be noted that:

My Fedora19 without fastest-mirror, it is best to install this Yum plug-in, otherwise the download may slow the dead;

If the system does not take the C library manual, in order to facilitate the coding of Lookup C library functions, please yum install man-pages.

The configuration process includes Linux kernel parameter optimization (/etc/sysctl.conf), Nginx source configuration (can be directly downloaded, decompressed, configure, make, makes install), Nginx.conf's configuration, according to the original book is, nginx.conf's specific practice is left below. But you can take the original book to learn the Configure file, this is a general skill under Linux.

In addition, in order to facilitate the use, I set up a soft link: first delete/usr/bin/nginx, and then Ln-s/usr/local/nginx/sbin/nginx/usr/bin/nginx.

Ii. the realization of HelloWorld

Nginx encapsulates a number of data structures, you know, you'll need them right away. Follow the third chapter of the idea, to know how to write their own modules into the Nginx: the simplest and less error-prone method is to write config file, which includes the module name, all the module name (using recursive Assignment), module source code path, the original book example:

Ngx_addon_name=ngx_http_mytest_module
http_modules= "$HTTP _modules ngx_http_mytest_module"
NGX_ADDON_ srcs= "$NGX _addon_srcs $ngx _addon_dir/ngx_http_mytest_module.c"
    
config file

Then use C language to write module source code. The book introduces a few data structures and functions, after combing, their relationship is this:

More Wonderful content: http://www.bianceng.cnhttp://www.bianceng.cn/Servers/web/

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.