nginx installation deployment

Usually there is an app server in the test environment, just install the deployed application directly.

However, there are multiple app application servers in production, at this time a web(nginx) server is needed to access multiple nginx servers randomly, and the effect of load balancing is also needed.

Server List:

There are three app application servers in production (these three uniformly installed jar packages or war packages, if the port number of the deployed application is 8080 and the context root is tcrl):

1 web (installing nginx) server:

This is when you need to install nginx on your web server.

The first step is to have the root user of the nginx server.

root user logged in to web server:

groupadd nginx >Establish nginx group

useradd -g nginx nginx > Establish nginx User-specified nginx user group

cd /usr

mkdir nginx

chown -R nginx:nginx /usr/nginx > Modify the users and groups to which the file belongs chown

/usr/nginx This directory is the installation directory of nginx, primarily giving nginx users permissions to this directory so that nginx can be installed in this directory.

Reset nginx user password

[root@eshop-cache01 ~]# passwd nginx
Changing password for user nginx.
New password: 
BAD PASSWORD: The password is shorter than 8 characters
Retype new password: 
passwd: all authentication tokens updated successfully.
[root@eshop-cache01 ~]# 

Now you can switch user installations.

Su nginx > Switch users or log in directly based on the reset nginx user and password

Download nginx, zlib, pcre, download directly if the server has a network, and upload the resources to the server if it has no network.


My direct download (upload directory) is/home/nginx

[nginx@eshop-cache01 ~]$ wget
--2021-06-15 13:51:46--
Resolving (
Connecting to (||:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 607698 (593K) [application/x-gzip]
Saving to: Holmium lib-1.2.11.tar.gz Holmium

100%[==================================================================================================================================================================================================>] 607,698     16.4KB/s   in 23s    

2021-06-15 13:52:14 (26.3 KB/s) - Holmium lib-1.2.11.tar.gz Holmium saved [607698/607698]

[nginx@eshop-cache01 ~]$ wget
--2021-06-15 13:54:49--
Resolving (
Connecting to (||:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 2090750 (2.0M) [application/x-gunzip]
Saving to: Hollywood cre-8.44.tar.gz Holmium

100%[==================================================================================================================================================================================================>] 2,090,750    880KB/s   in 2.3s   

2021-06-15 13:54:52 (880 KB/s) - Hollywood cre-8.44.tar.gz Holmium saved [2090750/2090750]

[nginx@eshop-cache01 ~]$ wget
--2021-06-15 13:55:00--
Resolving (,, 2a05:d014:edb:5704::6, ...
Connecting to (||:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1043748 (1019K) [application/octet-stream]
Saving to: Holmium ginx-1.19.0.tar.gz Holmium

100%[==================================================================================================================================================================================================>] 1,043,748    570KB/s   in 1.8s   

2021-06-15 13:55:02 (570 KB/s) - Holmium ginx-1.19.0.tar.gz Holmium saved [1043748/1043748]

Then start decompressing:

tar -zxvf nginx-1.19.0.tar.gz
tar -zxvf  pcre-8.44.tar.gz
tar -zxvf zlib-1.2.11.tar.gz


  Start installation:

Installation sequence is: pcre, zlib, nginx

cd  pcre-8.44
./configure > Errors found: configure: error: Invalid C++ compiler or C++ compiler flags
 Therefore, installation is required c++
yum install gcc-c++
Then an error occurred: You need to be root to perform this command.
Meaning is to use root User Installation c++Choke, use root User Execution yum install gcc-c++Continue after success nginx User Installation
cd /home/nginx/pcre-8.44
./configure >It's a success
make && make install > Error again  cannot create regular file '/usr/local/lib/': Permission denied
 Explain nginx User does not/usr/local Directory permissions, so use root User Execution chown -R nginx:nginx /usr/local
 Continue after successful execution nginx User Installation
make && make install
cd  zlib-1.2.11
make && make install
cd  nginx-1.19.0
./configure --prefix=/usr/nginx
make && make install

Except when the pcre was installed with a small twist, it worked well afterwards.

Start backing up and writing the nginx.conf configuration file after the nginx installation is successful.

cd /usr/nginx/conf
cp nginx.conf nginx.conf_bak

After installation, nginx.conf will not explain, just how to change it:


	upstream tcrlServer { > Here's a new configuration to fill in the multiple sets at the beginning of the article app Application Server.
						  >tcrlServer You can add multiple configurations with different names
		ip_hash; >Represents load balancing

    server {
        listen       8080; 			>nginx Server Access Address
        server_name;  >nginx Server Port

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   html;
            index  index.html index.htm;
		location /tcrl { >Here is the new configuration, interception context root is tcrl Request for
            root   tcrlServer;>I've forgotten about the configuration here. I'll modify it later

All that's left is to start

. /ngix-t/usr/nginx/conf/nginx.conf Detection Profile
. /ngix-c/usr/nginx/conf/nginx.conf > Start nginx

Ps-ef|grep nginx initiates two more processes after error-free startup: master and waker


Then you can access: La

  welCome is a success.

Visit ******* Requests for paths are automatically randomized to the following three servers:*********************

Tags: Operation & Maintenance Nginx server

Posted on Sat, 30 Oct 2021 14:35:59 -0400 by Pazuzu156