Nginx installation and use tutorial, nginx use tutorial

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

Nginx installation and use tutorial, nginx use tutorial
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.

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.
3. 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 the load evenly, so that a server is not idle due to the high load of a server.

Required installation environment

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

Installation Steps

Step 1: Upload the nginx source code package to the linux System

Step 2: Extract
[Root @ localhost ~] # Tar zxf nginx-1.8.0.tar.gz
Step 3: Use the configure command to create a makeFile.

./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
Step 4: make
Step 5: make install
Step 6: Go to the local directory and find the nginx folder.

Step 7: Enter sbin

[Root @ localhost sbin] # mkdir/var/temp/nginx/client-p
Note: Before starting nginx, specify the temporary file directory as/var/temp/nginx. Create the temp and nginx directories under/var.

Start nginx

Go to the sbin directory and start
[Root @ localhost sbin] #./nginx
Start and view

[Root @ localhost sbin] #./nginx-s stop
Recommended:
[Root @ localhost sbin] #./nginx-s quit

Restart nginx:
1. Close and start.
2. Refresh the configuration file:
[Root @ localhost sbin] #./nginx-s reload

Access nginx

Access started nginx through the browser: ip + port 80

Disable nginx:
The default port is port 80.
Note: Disable the firewall.

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.