Nginx introduction and installation details, Nginx introduction and Installation Details

Source: Internet
Author: User
Tags openssl library what is nginx

Nginx introduction and installation details, Nginx introduction and Installation Details

1. What is nginx?

Nginx is a high-performance http server/reverse proxy server and email (IMAP/POP3) proxy server.

Developed by Russian programmer Igor Sysoev, the official test nginx can support 50 thousand concurrent connections, and its cpu, memory, and other resources are very low and run very stably.

2. Application scenarios

1. http server. Nginx is an http service that provides http services independently. Web static servers can be used.

2. VM. Multiple websites can be virtualized on one server. For example, the virtual host used by a personal website.

Reverse proxy and Server Load balancer. When a website's access volume reaches a certain level and a single server cannot meet users' requests,

You need to use multiple Server clusters to use nginx for reverse proxy. In addition, multiple servers can carry load evenly,

It won't happen if a server is idle due to high load downtime

3. Install nginx

1. environment required for Installation

1. The gcc environment needs to be installed. Yum install gcc-c ++

2. Third-party development kits.

① PCRE

PCRE (Perl Compatible Regular Expressions) is a Perl library, including a perl-Compatible Regular Expression Library. The http module of nginx uses pcre to parse regular expressions. Therefore, you need to install the pcre Library on linux.

Yum install-y pcre-devel

Note: pcre-devel is a secondary development library developed using pcre. Nginx also needs this library.

② Zlib

The zlib library provides many compression and decompression methods. nginx uses zlib to perform gzip on the http package content. Therefore, you need to install the zlib library on linux.

Yum install-y zlib-devel

③ Openssl

OpenSSL is a powerful secure socket-layer cryptographic library that includes major cryptographic algorithms, common keys, certificate encapsulation management functions, and SSL protocols, and provides a wide range of applications for testing or other purposes.

Nginx not only supports http protocol, but also https (Transmission of http over ssl protocol). Therefore, you need to install the openssl library in linux.

Yum install-y openssl-devel

3. The version used here is the link of 1.8.0: https://pan.baidu.com/s/1pMTTjhp password: pl4h

Run the following command after passing in the server:

Decompress:

Tar-zxvf nginx-1.8.0.tar.gz

Cd nginx-1.8.0

Parameter settings:

./Configure \

-- Prefix =/usr/local/nginx \

-- Pid-path =/var/run/nginx. pid \

-- Lock-path =/var/lock/nginx. lock \

-- Error-log-path =/var/log/nginx/error. log \

-- Http-log-path =/var/log/nginx/access. log \

With-http_gzip_static_module \

-- Http-client-body-temp-path =/var/temp/nginx/client \

-- Http-proxy-temp-path =/var/temp/nginx/proxy \

-- Http-fastcgi-temp-path =/var/temp/nginx/fastcgi \

-- Http-uwsgi-temp-path =/var/temp/nginx/uwsgi \

-- Http-scgi-temp-path =/var/temp/nginx/scgi

Note: Specify the temporary file directory as/var/temp/nginx. Create the temp and nginx directories under/var.

Ii. Compilation and Installation

Run make install

After the installation is successful, view the directory:

Iii. Start and close

① Start

Create a temporary file directory mkdir/var/temp/nginx-p before starting nginx.

Go to the sbin directory under nginx and use./nginx

View the ps aux | grep nginx process after the startup is successful (if the two processes marked in red boxes exist, the start is successful)

② Close

Method 1: Stop quickly:

Cd/usr/local/nginx/sbin

./Nginx-s stop

This method is equivalent to first identifying the nginx process id and then using the kill command to forcibly kill the process.

Method 2: complete stop (recommended ):

Cd/usr/local/nginx/sbin

./Nginx-s quit

The stop process is to stop the nginx process after processing the task.

Iv. Test

This page appears when you access the Virtual Machine address. This indicates that nginx is successfully installed.

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.