Nginx concept and Basic installation--detailed explanation

Source: Internet
Author: User
Tags install openssl

1. Main content:

The foundation of Nginx
Characteristics
Configure deployment
Optimization (understanding)

What is 2.Nginx?

Nginx is an open source, supporting high-performance, high-concurrency WWW service and Proxy service software---Web services software.
It was developed by the Russian Igor Sysoev,
Advantages:

        Performance: Consumes less system resources, 30,000 concurrently turns on 10 threads small Memory 200MB            supports more concurrent connections, tens of thousands of concurrency trivial to            achieve higher access efficiency            support for asynchronous network I/O event model Epoll (Linux 2.6+)
        Features: Excellent Web services software, support for reverse proxy load balancing and caching service                                 agent software: LVS, Haproxy and other software, why choose?                                             Nginx deployment is simpler and more convenient.                                 cache: He is similar to cache service software (seldom used)                                         using its own Proxy_cache module to achieve professional caching such as squid class
        Installation configuration: More convenient, simple, flexible                supported operating systems:                    unix,bsd,mac os X,  solaris,linux,   Microsoft and other operating systems                commonly used in combination environments: Lnmp or Lemp (E Engine x from Nginx)

2015 Web services software rankings:
1.apache 32.4%
2.Nginx 14.29%
3.microsoft [La?t] [spi?d] 31.65% IIS
4.google Servers 2.07%
5.tomcat 0.4%

Basic features of 3.Nginx
    A) high-speed concurrent access to static resources and cache    B) can use reverse proxy acceleration, and data caching is possible.    c) With simple load balancing, node monitoring detection and fault tolerance    D) cache acceleration support for FASTCGI Services        CGI full name is "Public Gateway Interface" (Common gateway Interface),        An HTTP server is a tool for "talking" with programs on your or other machines, and        its programs typically run on a Web server.        CGI can be written in any language, as long as the language has standard input, output, and environment variables.        such as PHP,PERL,TCL and so on.        compared to CGI, FASTCGI has two points that are different from it. The        1th is that the fastcgi process is permanent, meaning that the process used to process the request does not exit as the request ends, but continues to run waiting for new requests to be processed.        this solves the performance problems of CGI due to frequent creation and shutdown processes, and 2nd, the        communication between fastcgi and Web servers is different from CGI.        and communication at full duplex mode    f) supports fastcgi, Uwsgi, scgi, Memcached servers acceleration and cache    g) with modular architecture

4.nginx has other WWW service features:

    A) support for multiple virtual host sites based on name, port and IP: Port-based, IP, domain    c) for simple, convenient, flexible configuration and Management    D) Support modification of nginx configuration and smooth restart smooth restart when code is online        :                nginx Runs a new worker process and gracefully shuts down the old worker process, notifies the worker process to close the listener socket,            but continues to service the currently connected client            after all client services are completed, the old worker process is closed    e) can customize the Access log format, temporarily buffer the write log operation, Fast log polling and Rsyslog processing log    f) can use signal control Nginx process kill-l    g) Support rewrite module, support URI rewrite and regular expression matching    h) support FLV stream and MP4 Stream technology product application    I) Support HTTP response rate limit    J) support for the same IP address concurrent connection or request limit    K) supports the Mail service proxy
Compile and install Nginx environment:

1. Preparatory work:

    1. View current system version: Cat/etc/redhat-release  --centos6.7    yum-y install lrzsz    yum-y Install open gcc    uname- A

2. Install Nginx required Pcre Library and some packages--use (for Nginx to have URI rewriting function rewrite)

        Typically Yum:        Configure a Yum source (using a network source)        yum-y install OpenSSL openssl-devel gcc gcc-c++        yum-y install pcre pcre-devel
    View version: Rpm-qa pcre

3. Select version:

        Stable version, development version, stable version of the first stable edition        (the latest version of the late 6-10 months is good)

4. Install openssl-devel for God's horse, because the HTTPS service requires this module
What is HTTPS?

               A) HTTP is called Hypertext Transfer Protocol, using TCP port 80, by default the data is transmitted in clear text, the               data can be captured through the capture tool, so on the Internet,               Some of the more important sites HTTP servers need to use PKI (Public Key Infrastructure) technology to encrypt data!               This is HTTPS,            B) HTTPS is called a secure Hypertext Transfer protocol, using TCP port 443,            his data will be encrypted with the public key in the PKI,            so that the packet caught by the capture tool is not able to see the contents of the package, Security is greatly improved and the            private key in the PKI is used to decrypt the data.            
View Code

5.mkdir/app

Cd/app--for the existence of various software wget-Q http://nginx.org/download/nginx-1.6.3.tar.gz--Download packagels--view the files in the current directory to see if nginx download completed useradd nginx-S/SBIN/NOLOGIN-M Create an Nginx user and prohibit this user from logging on to the system-M does not create a user directory-s user login after using the shell name, actually here is not allowed to login system tail-1/etc/passwd to see if a user exists with the tar XF nginx-1.6.3. tar.gz-Unzip the CD Nginx-1.6.3--enter the unzip directory./Configure Configuration--user=nginx Process User Rights--group=nginx Process user group permissions--prefix=/usr/local/nginx1.4.5Setting the installation path--with-http_stub_status_module activation status information--with-http_ssl_module activating SSL feature make compile make install installation
Installation Commands

6. Check the configuration file syntax before you start the installation is not complete at this time

        /usr/local/nginx1.6.3/sbin/nginx-t        in the Start service money detection syntax is very important to prevent a configuration error caused by a site restart or reload configuration        and other user impact

7. Start the Nginx service

        /usr/local/nginx1.6.3/sbin/nginx

8. To see if the service started successfully, method: View Port

        Lsof-i:        netstat-lnt | grep 80

9. Visit 127.0.0.1 | Curl 127.0.0.1

10. Summary: Install errors that occur easily:

        1.nginx: [Emerg] Getpwnam ("Nginx") failed        2. Cannot access page:            1. Turn off SELinux setenforce 0--method of temporarily closing SELinux getenforce (view)            2. Turn off firewall/etc/init.d/iptables stop  -temporarily turn off firewall            3. View log: Cat/usr/local/nginx1.6.3/logs/error.log            4. Ping IP and view ports

One. server {
Listen 80;
server_name localhost;
Location/{
root HTML; ----------/home/www---Change the site root directory
Index index.html index.htm;
}

12. Restart the service

Method 1: Kill the process restart

        A)        kill process        lsof-i:        kill-9 pid        restart        /usr/local/nginx1.6.3/sbin/nginx        b)        Ps-ef | awk ' {print $} ' |  Xargs kill-9        /usr/local/nginx1.6.3/sbin/nginx

Method 2: Configure file restart

        A)    check syntax/usr         /local/nginx/sbin/nginx-t        /usr/local/nginx/sbin/nginx-c/usr/local/nginx/conf/ Nginx.conf-        c The path of the configuration file, without the-c Nginx will automatically load the default path of the configuration file.        b)        /USR/LOCAL/NGINX/SBIN/NGINX-T Check Syntax        /usr/local/nginx/sbin/nginx-h  --View help        #-s signal:send signal to a Master Process:stop, quit, reopen, reload        /usr/local/nginx/sbin/nginx-s  Reload (Reload if the syntax error does not succeed, Sometimes not output error)        c) The        nginx boot file in the/ETC/INIT.D inside the        server nginx restart        chkconfig--add nginx---meaning is power on from the start

Nginx concept and Basic installation--detailed explanation

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.