First, install Tomcat
1. Upload the Tomcat installation package to Linux;
2. Unzip 2 Tomcat and modify the name separately:
1), decompression command: Unzip
2), modify the user name: MV
3, modify the port number of two Tomcat, modify the file:
The first port number can be used with the default of 8080:
To modify the port number for the second set:
4. Launch two Tomcat and visit the local browser to see if it is normal:
First set:
Second set:
Note: If two Tomcat deploys the same project, the same database name can be selected at installation so that two services can be shared with the same database
Two, installation
1, install the compilation tools and library files
Yum-y install make zlib zlib-devel gcc-c++ libtool OpenSSL openssl-devel
2, install Pcre: let Nginx support Rewrite function
2.1), download the Pcre installation package:
wget http://downloads.sourceforge.net/project/pcre/pcre/8.35/pcre-8.35.tar.gz
2.2), unzip the installation package: TAR-ZXVF pcre-8.35.tar.gz
2.3), enter into the directory: CD pcre-8.35
2.4), compile:./configure
2.5), install: Make && make install
2.6), view version: Pcre-config--version
3. Installing Nginx
1), download the Nginx installation package, download to the official website, here is a stable version
2), upload the installation package to Linux
3), Decompression Nginx installation package: TAR-ZXVF nginx-1.14.0.tar.gz
4), enter into the Nginx directory, unzip the installation:./configure && make && make install
5), start Nginx, can be through: Whereis Nginx to see which path the Nginx installation, enter the path and start:
6), open in browser, enter virtual machine IP: Port number:
4. Configure Nginx
1), First close Nginx:ps-ef | grep Nginx | Grep-v grep | awk ' {print $} ' |xargs kill-9
2), edit nginx configuration file: vim/usr/local/nginx/conf/nginx.conf
3), restart Nginx, enter the/usr/local/nginx/sbin/directory, execute./nginx
4), enter ip:81 (port)/javashop (app service) in a different browser window, and you can log in.
Note: Different Windows perform operations, and by looking at the service log of Javashop under each tomcat, you can detect which service is being accessed.
Frequently encountered problems:
1. When you start Nginx, prompt error
Workaround:
1), use Whereis libpcre.so.1 command to find libpcre.so.1 where
2), with Ln-s/usr/local/lib/libpcre.so.1/lib command to make a soft connection on it.
3), re-enter Nginx, start can
2. When you start Nginx, the port is already occupied, as shown below:
Workaround:
1), open the nginx.conf file, modify the port number:
2), start again.
Build a Nginx+2tomcat load balancing environment under Linux