Nginx service and compilation and installation, Nginx service compilation and Installation

Source: Internet
Author: User
Tags node server aliyun

Nginx service and compilation and installation, Nginx service compilation and Installation
Chapter 2 Nginx1.1 nginx Concept

Nginx ("engine x") is an open-source, high-performance, high-concurrency WWW Service and proxy service software with high development (especially static resources ), features such as low usage of system resources.

Nginx can run on Unix, Linux, BSD, Mac OSX, Solaris, Microsoft Windows, and other operating systems. As Nginx runs stably and efficiently on many large websites in China, in the past two years, it has gradually been used by more and more small and medium-sized websites. The popular Nginx Web combination is called LNMP or LEMP (that is, Linux + Nginx + MySQL + PHP)

Http://oldboy.blog.51cto.com/2561410/775056

Https://www.unixhot.com/page/ops

Https://www.unixhot.com/page/cache

1.2 important features and application scenarios of Nginx 1.2.1 *** important features of Nginx

01.High concurrency: Supports tens of thousands of concurrent connections (especially for static small file business environments)

02.Low resource consumption: With 30 thousand concurrent connections, enabling 10 Nginx threads consumes less than 200 MB of memory

03. You can perform HTTP reverse proxy and accelerate cache, that isServer Load balancer[OSI Layer 4-7]

Built-in RS node server health check function, equivalent to professional Haproxy software or LVS [Layer 4] Function

04. Have Squid and so onData CacheSoftware and other caching functions (mencache/redis)

05. SupportedAsynchronous NetworkI/O business model epoll (Linux 2.6 +)

1.3 Main enterprise functional applications of Nginx Software

01. Support website page request processing as a web Service

02. Support reverse proxy or load balancing

03. frontend service data cache service (expansion)

 

Chapter 4 compile and install Nginx

Server Configuration:

2.1 ① check the software installation environment

1 cat/etc/redhat-release # view the software system environment 2 3 uname-r

2.2 ② install nginx dependency packages
1 yum install-y pcre-devel openssl-devel 2 3 rpm-qa pcre-devel openssl-devel # Check the installation result after installing yum

Extension:

Pcre: compatible with perl compatible regular expressions and perl compatible regular expressions

Rewirte module parameter information (perl-defined regular expression)

Openssl: ssh --- openssh/openssl --- https

2.3 ③ download nginx software 2.3.1 change yum Source

Http://mirrors.aliyun.com/

1 wget-O/etc/yum. repos. d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo

2.3.2 put in a unified directory and install
1 mkdir -p /server/tools2 3 cd /server/tools4 5 wget http://nginx.org/download/nginx-1.10.2.tar.gz

Note: For more Nginx versions, see http://nginx.org/select to install stable version (stable version)

2.3.3 decompress the nginx package

1 tar xf nginx-1.10.2.tar.gz

2.3.4 create a virtual user www to manage nginx

1 useradd www-s/sbin/nologin-M 2 3 id www

2.4 ④ steps for compiling and installing software

Configure [. configure] --> cooking [compile make] --> serving [install make stall])

2.4.1 configuration software (installed on/usr/local by default)
1 mkdir-p/server/tools/nginx-1.10.22 3 cd/server/tools/nginx-1.10.24 5. /configure -- prefix =/application/nginx-1.10.2 -- user = www -- group = www -- with-http_stub_status_module -- with-http_ssl_module # Start the corresponding module

Note:-- Prefix: Specifies the directory to which the software is installed. If the specified directory does not exist, it is automatically created.

-- User/-- group: IndicatesNginxUser used by the worker process/User Group Operation Management

With-http_stub_status_module: StartNginxStatus Module Function(User AccessNginxNetwork Information)

With-http_ssl_module: StartHttpsFunction module

1 echo $?

(The return value is used to determine whether the operation is correct during software compilation .)

2.4.1.1 specified parameters and simple descriptions

When compiling Nginx software, you can use./configure -- help to view relevant parameter help.

1 -- prefix = PATH # <--- set installation PATH 2 -- user = USER # <--- Process user Permissions 3 -- group = GROUP # <--- process USER group permissions 4 -- with-http_stub_status_module # <--- Activation status information 5 -- with-http_ssl_module # <--- activate ssl
2.4.2 compile and install software (errors will be reported if the order is reversed)

1 make # compile software -- convert to binary software package so that the computer can recognize 2 3 make install # compile and install

2.4.3 create a soft link to the directory

1 cd/application/2 3 ln-s/application/nginx-1.10.2 // application/nginx

Purpose: Change the Nginx installation path to/application/nginx through soft connections, so that the version name does not need to be reset when the program code calls the nginx program.

2.4.4 start the nginx Process

1/application/nginx/sbin/nginx

2.4.5 check service process port information
1 ps-ef | grep nginx2 3 root 4142 1 0 21:32? 00:00:00 nginx: master process/application/nginx/sbin/nginx # master process 4 www 4143 4142 0? 00:00:00 nginx: worker process # process user requests

Test on the client:

2.4.6 check the actual effect of Nginx startup

In Windows, browser detection is performed as follows:

Open the browser and enter: http: // 10.0.0.8/(10.0.0.8 is the IP address of the Nginx server installed) → press ENTER

Note: domain names cannot be used for access. If you want to use a domain name for access, you need to modify the local hosts file (you cannot use the built-in IE browser)

 

In linux, browser detection is performed as follows:

1 [root @ web01 ~] # Wget 127.0.0.1 2 3 -- 17:35:35 -- http: // 127.0.0.1/4 is connecting 127.0.0.1: 80... already connected. 5. An HTTP request has been sent and is waiting for a response... 200 OK 6 length: 612 [text/html] 7 is being saved: export index.html "8 9 100% [==================================== ========================================================== ======>] 612 --. -K/s in 0s10 11 17:35:35 (120 MB/s)-saved index.html "[612/612])

 

 

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.