Background: Connect to the server using Windows PowerShell and install Ngnix

Install and compile tools and library files

yum -y install make zlib zlib-devel gcc-c++ libtool  openssl openssl-devel
Copy the code

Two, install PCRE

The PCRE function is to make nginx support Rewrite functionality

1. Download the PCRE installation package

Download address: downloads.sourceforge.net/project/pcr…

[root@cloud-service /]# cd /usr/local/src/
[root@cloud-service src]# wget http://downloads.sourceforge.net/project/pcre/pcre/8.43/pcre-8.43.tar.gz
Copy the code

2. Decompress the installation package

[root@cloud-service SRC]# tar ZXVF Pcl-8.43.tar.gzCopy the code

3. Go to the installation directory

[root @ cloud - service SRC] # CD pcre - 8.43Copy the code

4. Compile and install

[root@cloud-service pcre-8.43]#./configure [root@cloud-service pcre-8.43]# make && make installCopy the code

5. View the PCRE version

[root @ cloud - service pcre 8.43] # pcre - config - versionCopy the code

If the version number is displayed, the installation is successful.

Install Nginx

1. Download Nginx

Download: nginx.org/download/ng…

# / root @ cloud service/CD/usr/local/SRC / [root @ cloud - service SRC] # wget HTTP: / / http://nginx.org/download/nginx-1.18.0.tar.gzCopy the code

2. Decompress the installation package

[root@cloud-service src]# tar zxvf nginx-1.18.0.tar.gz  
Copy the code

3. Go to the installation directory

[root @ cloud - service SRC] # CD nginx - 1.18.0Copy the code

4. Compile and install

[root @ cloud - service nginx - 1.18.0] #. / configure -- prefix = / usr/local/webserver/nginx - with - http_ssl_module --with-http_gzip_static_module --with-pcre=/usr/local/ SRC /pcre-8.43 [root@cloud-service nginx-1.18.0]# make && make installCopy the code

The meanings of configuration items during compilation are as follows:

–prefix=PATH: Sets the installation directory PATH

— with-http_SSL_module: Enable the HTTP_SSL module for building HTTPS services. This module is not built by default.

— with-http_gzip_STATIC_module: enable the HTTP_Gzip_Static module, which compresses static content into a precompressed file with a “.gz” file extension and caches it locally. This file will be sent in response instead of a regular file. The advantage of using this module is that you do not need (Gzip) to process and compress files every time they are transferred. This module is not built by default

–with-pcre=DIR: If you install the pcRE library source code, you need to set the directory path of the PCRE library.

You can view other configuration items and their meanings by running./configure –help

5. Check the Nginx version

[root @ cloud - service nginx - 1.18.0] # / usr/local/webserver/nginx/sbin/nginx -v nginx version: nginx / 1.18.0Copy the code

If the version number is displayed, the installation is successful.

Nginx common commands

1. Specify the Nginx configuration file

[root@cloud-service /]# /usr/local/webserver/nginx/sbin/nginx -c /usr/local/webserver/nginx/conf/nginx.conf
Copy the code

-c indicates configuration, which specifies the configuration file.

2. Check whether the Nginx configuration file is correct

[root@cloud-service /]# /usr/local/webserver/nginx/sbin/nginx -t
Copy the code

3. Start Nginx

[root@cloud-service /]# /usr/local/webserver/nginx/sbin/nginx
Copy the code

4. Stop Nginx (by sending a request to Nginx)

[root@cloud-service /]# /usr/local/webserver/nginx/sbin/nginx -s stop
[root@cloud-service /]# /usr/local/webserver/nginx/sbin/nginx -s quit
Copy the code

-s is used to send signals to Nginx.

5, Nginx overload configuration

[root@cloud-service /]# /usr/local/webserver/nginx/sbin/nginx -s reload
Copy the code

6. Display help information

[root@cloud-service /]# /usr/local/webserver/nginx/sbin/nginx -h
Copy the code

7. Check the Nginx process

[root@cloud-service /]# ps -ef | grep nginx
root     25900     1  0 13:42 ?        00:00:00 nginx: master process /usr/local/nginx/sbin/nginx
root     25901 25900  0 13:42 ?        00:00:00 nginx: worker process
root     29166  4225  0 15:03 pts/0    00:00:00 grep --color=auto nginx
Copy the code

Stop the Nginx process

Find the main process number 25900 in the process list

Stop Nginx leisurely:

[root@cloud-service /]# kill -QUIT 25900
Copy the code

Quick stop Nginx:

[root@cloud-service /]# kill -TERM 25900
Copy the code

Forcibly stop Nginx:

[root@cloud-service /]# pkill -9 nginx
Copy the code