Home  >  Article  >  Backend Development  >  Detailed graphic tutorial for installing Nginx under Linux

Detailed graphic tutorial for installing Nginx under Linux

WBOY
WBOYOriginal
2016-08-08 09:20:05964browse

What is Nginx?

Nginx ("engine x") is a high-performance HTTP and reverse proxy server. It is also an IMAP/POP3/SMTP proxy server. In the case of high connection concurrency, Nginx is an Apache server. A good substitute. It is characterized by less memory and strong concurrency. In fact, nginx’s concurrency capability does perform better among web servers of the same type. Currently, the users of nginx websites in mainland China include: Sina, NetEase, Tencent, and others The well-known microblog Plurk also uses nginx.

Nginx as a load balancing server:

Nginx can not only directly support Rails and PHP programs internally to provide external services, but also support external services as an HTTP proxy server. Nginx is written in C, and its system resource overhead and CPU usage efficiency are much better than Perlbal. As a mail proxy server:

Nginx is also a very good mail proxy server (one of the earliest purposes of developing this product is also as a mail proxy server), Last.fm describes the successful and wonderful use experience. Nginx is a server that is very easy to install, has a very concise configuration file (it can also support perl syntax), and has very few bugs: Nginx is particularly easy to start and can run almost 7*24 without interruption, even if it runs for several months. Restart. You can also upgrade the software version without interrupting service.

Nginx installation

Module dependencies Nginx needs to depend on the following 3 packages

1. The gzip module requires the zlib library (Download: http://www.zlib.net/ )

2. The rewrite module requires the pcre library (Download: http://www.pcre.org/)

3. The ssl function requires the openssl library (Download: http://www. openssl.org/ )

Nginx package download: http://nginx.org/en/download.html

The dependency package installation order is: openssl, zlib, pcre, and then install the Nginx package.

Illustrated tutorial

Step 1: Download and install the required packages

openssl-fips-2.0.2.tar.gz

zlib-1.2.7.tar.gz

pcre-8.21.tar.gz

nginx-1.2.6.tar.gz

Step 2: Install openssl-fips-2.0 in sequence. 2.tar.gz, zlib-1.2.7.tar.gz, pcre-8.21.tar.gz, nginx-1.2.6.tar.gz

1. Install openssl-fips-2.0.2.tar. gz

<span>[root@localhost mrms]# <span>tar</span> -zxvf openssl-fips-<span>2.0</span>.<span>2</span>.<span>tar</span><span>.gz 

[root@localhost mrms]# cd openssl</span>-fips-<span>2.0</span>.<span>2</span><span>[root@localhost openssl</span>-fips-<span>2.0</span>.<span>2</span>]# ./<span>config 

[root@localhost openssl</span>-fips-<span>2.0</span>.<span>2</span>]# <span>make</span><span>[root@localhost openssl</span>-fips-<span>2.0</span>.<span>2</span>]# <span>make</span><span>install</span></span>

2. Install zlib-1.2.7.tar.gz

<span>[root@localhost mrms]# <span>tar</span> -zxvf zlib-<span>1.2</span>.<span>7</span>.<span>tar</span><span>.gz

[root@localhost mrms]# cd zlib</span>-<span>1.2</span>.<span>7</span><span>[root@localhost zlib</span>-<span>1.2</span>.<span>7</span>]# ./<span>configure 

[root@localhost zlib</span>-<span>1.2</span>.<span>7</span>]# <span>make</span><span>[root@localhost zlib</span>-<span>1.2</span>.<span>7</span>]# <span>make</span><span>install</span></span>

3. Install pcre-8.21.tar.gz

<span>[root@localhost mrms]# <span>tar</span> -zxvf pcre-<span>8.21</span>.<span>tar</span><span>.gz

[root@localhost mrms]# cd pcre</span>-<span>8.21</span><span>[root@localhost pcre</span>-<span>8.21</span>]# ./<span>configure 

[root@localhost pcre</span>-<span>8.21</span>]# <span>make</span><span>[root@localhost pcre</span>-<span>8.21</span>]# <span>make</span><span>install</span></span>

4. Install nginx -1.2 .6.tar.gz

<span>[root@localhost mrms]# <span>tar</span> -zxvf nginx-<span>1.2</span>.<span>6</span>.<span>tar</span><span>.gz 

[root@localhost mrms]# cd nginx</span>-<span>1.2</span>.<span>6</span><span>[root@localhost nginx</span>-<span>1.2</span>.<span>6</span>]# ./configure --with-pcre=../pcre-<span>8.21</span> --with-zlib=../zlib-<span>1.2</span>.<span>7</span> --with-openssl=../openssl-fips-<span>2.0</span>.<span>2</span><span>[root@localhost nginx</span>-<span>1.2</span>.<span>6</span>]# <span>make</span><span>[root@localhost nginx</span>-<span>1.2</span>.<span>6</span>]# <span>make</span><span>install</span></span>

Now the installation of Nginx is completed!

Step 3: Check whether the installation is successful

<span>[root@localhost nginx-<span>1.2</span>.<span>6</span>]# cd  /usr/local/nginx/<span>sbin

[root@localhost sbin]# .</span>/nginx -t</span>

The following prompt appears, indicating that the installation is successful

Start nginx

<span>[root@localhost sbin]# ./nginx</span>

View the port

<span>[root@localhost sbin]# netstat -ntlp</span>

The results are as follows

Please indicate the source when reprinting [http://www .cnblogs.com/dennisit/archive/2012/12/26/2834719.html]

The above introduces the detailed graphical tutorial for installing Nginx under Linux, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn