Nginx server Basics

Source: Internet
Author: User

Nginx server Basics

 

I. Nginx Introduction

Nginx: Nginx is a software server (lightweight). Therefore, its primary function can be combined with server hardware. Our applications can be released on the nginx server, the effect has been achieved by netizens. In addition, Nginx is a high-performance Http and reverse proxy server and a proxy email server. That is to say, nginx can publish websites, load balancing, and sending and receiving emails as mail servers. Nginx supports processing millions of TCP connections, over 10 concurrent connections, and cross-platform.

Load Balancing: Server Load balancer is built on the existing network structure, it provides a cheap, effective, and transparent method to expand the bandwidth of network devices and servers, increase throughput, enhance network data processing capabilities, and improve network flexibility and availability. Server Load balancer has two meanings: first, a large amount of concurrent access or data traffic is distributed to multiple node devices for separate processing, reducing the user's waiting for response time. Second, the operation of a single heavy load is distributed to multiple node devices for parallel processing. After each node device finishes processing, the results are summarized and returned to the user, which greatly improves the system processing capability.

Nginx is more efficient than Windows in Linux.

Disadvantage: the rewrite function is not powerful enough, and there are not many Apache modules.

Rewrite:It is a server rewriting technology that enables the server to support URL rewriting. It is a new and popular server technology. It can also restrict specific IP addresses to access websites.

Ii. Install Nginx in Centos

1. Download nginx-1.8.1.tar.gz
2. Decompress tar-zxvf nginx-1.8.1.tar.gz
3. Go to the nginx-1.8.1 directory and then./configure will have an error./configure: error: C compiler cc is not found
This is because a gc ++ library is missing
4. Install the library file
(A) enter the root permission
(B) install the gc ++ library yum-y install gcc-c ++ autoconf automake
(C), Complete! Indicates that the installation is successful.
5. Run the./configure prompt again in the nginx-1.8.1 directory./configure: error: the HTTP rewrite module requires the PCRE library. (the library File PCRE library is missing)
6. install the PCRE library and enter the root permission to execute yum-y install pcre-devel. The Complete is displayed! Indicates that the installation is successful.
7. run again in the nginx-1.8.1 directory./configure prompt./configure: error: the HTTP gzip module requires the zlib library. (the zlib library is missing)
8. install the zlib library and enter the root permission to execute yum-y install zlib-devel! Indicates that the installation is successful.
9. Go to the nginx-1.8.1 directory again and execute./configure appears as shown to indicate that the installation was successful

 


10. Execute the command make to show make [1]: Leaving directory '/webserver/nginx-1.8.1', which means make is complete
11. Run the command make install. make [1]: Leaving directory '/webserver/nginx-1.8.1' indicates nginx installation is complete.
12. Check whether the installation is successful and go to the usr/local directory to check whether the nginx directory exists.

Ii. Functions of various directories in nginx

 

Conf: nginx configuration information
Html: Web Application
Logs: Log
Sbin: nginx application, such as the Startup Program.

III. Basic nginx operations

1. Start nginx: Executable file path +-c + configuration file full path (nginx. conf)
[Root @ iZ28b4kreuaZ sbin] #/usr/local/nginx/sbin/nginx-c/usr/local/nginx/conf/nginx. conf
2. Stop nginx
(A) calmly stop giving the stop buffer time
Stop kill-QUIT + master process number by killing the process
View processes: ps-ef | grep nginx
Stop with ease: kill-QUIT 2072
(B) forcibly stop nginx, regardless of whether it can be stopped.
Pkill-9 nginx
(C), fast stop
Kill-TERM + master process number kill-TERM 2132
3. Restart
Method 1. (a) Verify that the configuration file is correct
Method 1: Enter the executable file directory (sbin) to execute./nginx-t
Method 2:/usr/local/nginx/sbin/nginx-t-c/usr/local/nginx/conf/nginx. conf
(B) enter the executable file directory (sbin)./nginx-s reload
Method 2: kill-HUP + master process number example: kill-HUP 2255
4. Close the Working Process
How to disable a worker process
Kill-WINCH + Worker Process number
5. Smooth Nginx upgrade
(1) upgrade nginx
Smooth upgrade: During the upgrade, processes that are running will not be stopped. These processes will continue to process received requests, but will not accept new requests, wait until the old process stops processing the request that is still being processed. During this smooth upgrade, new processes will be processed.
Force update: Stop the server and perform the upgrade. The running process is affected.
(2) smooth upgrade
(A) view the current version of sbin directory and execute./nginx-V
(B) download the version to be upgraded to the local nginx-1.9.2.tar.gz unzip and enter the nginx-1.9.2 directory to execute./configure and then execute make (do not execute make install again)
(C), the nginx-1.9.2/objs/directory under the executable file (nginx) copy to the/usr/local/nginx/sbin/directory (back up the ngin files of earlier versions before copying, for example, cp nginx. old; nginx. old is the backup file ).
(D), execute copy cp-rfp objs/nginx/usr/local/nginx/sbin under/nginx-1.9.2/directory
(E) delete the file nginx-1.9.2 and nginx-1.9.2.tar.gz for the upgraded version
6. Observe process changes
During smooth upgrade, run the command ps-ef | grep nginx to observe the process changes.

 

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.