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):
182.119.106.1
182.119.106.2
182.119.106.3
1 web (installing nginx) server:
182.119.3.51
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 182.119.1.1 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.
wget http://zlib.net/zlib-1.2.11.tar.gz wget http://ftp.pcre.org/pub/pcre/pcre-8.44.tar.gz wget http://nginx.org/download/nginx-1.19.0.tar.gz
My direct download (upload directory) is/home/nginx
[nginx@eshop-cache01 ~]$ wget http://zlib.net/zlib-1.2.11.tar.gz --2021-06-15 13:51:46-- http://zlib.net/zlib-1.2.11.tar.gz Resolving zlib.net (zlib.net)... 85.187.148.2 Connecting to zlib.net (zlib.net)|85.187.148.2|: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 http://ftp.pcre.org/pub/pcre/pcre-8.44.tar.gz --2021-06-15 13:54:49-- http://ftp.pcre.org/pub/pcre/pcre-8.44.tar.gz Resolving ftp.pcre.org (ftp.pcre.org)... 131.111.8.88 Connecting to ftp.pcre.org (ftp.pcre.org)|131.111.8.88|: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 http://nginx.org/download/nginx-1.19.0.tar.gz --2021-06-15 13:55:00-- http://nginx.org/download/nginx-1.19.0.tar.gz Resolving nginx.org (nginx.org)... 3.125.197.172, 52.58.199.22, 2a05:d014:edb:5704::6, ... Connecting to nginx.org (nginx.org)|3.125.197.172|: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/libpcre.so.1.2.12': 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 ./configure 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.
#backups 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 182.119.106.1:8080; server 182.119.106.1:8080; server 182.119.106.1:8080; } server { listen 8080; >nginx Server Access Address server_name 192.168.3.51; >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
/usr/nginx/sbin
. /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:
http://192.168.3.51:8080 La
welCome is a success.
Visit http://192.168.3.51:8080/tcrl/ ******* Requests for paths are automatically randomized to the following three servers:
http://182.119.106.1:8080/tcrl/*******
http://182.119.106.2:8080/tcrl/*******
http://182.119.106.3:8080/tcrl/*******