1. Install tomcat
https://blog.csdn.net/weixin_45955039/article/details/124282975?spm=1001.2014.3001.5501
2. Install nginx
https://blog.csdn.net/weixin_45955039/article/details/124282533?spm=1001.2014.3001.5501
3. Copy two copies of tomcat, namely tomcat1 and tomcat2
cd /usr/local/
mv tomcat/ tomcat1/
cp tomcat1/ tomcat2/
4. Modify the configuration file server.xml, mainly to modify the port number
4.1 There is no need to modify the one on tomcat1, go check it out
vim /usr/local/tomcat1/conf/server.xml
shutdown 端口:8005 主要负责启动关闭.
http端口:8080 可以通过web页面直接访问(nginx+tomcata整合)
4.2 Modify the port on tomcat2, change 8080 to 8081, change 8005 to 8006
vim /usr/local/tomcat2/conf/server.xml
5. Start two tomcat
5.1 start
[root@slave2 sbin]# cd /usr/local/tomcat1
[root@slave2 tomcat1]# bin/startup.sh
[root@slave2 sbin]# cd /usr/local/tomcat2
[root@slave2 tomcat2]# bin/startup.sh
5.2 View
http://192.168.1.103:8080/
http://192.168.1.103:8081/
6. Configure the nginx.conf file
[root@slave2 tomcat1]# cd /usr/local/nginx/
[root@slave2 nginx]# vim conf/nginx.conf
6.1 Add the following code to the file
upstream nini{
server 192.168.1.103:8080;
server 192.168.1.103:8081;
}
6.2 Add the following code in the location
proxy_pass http://nini;
7. Start nginx
vim conf/nginx.conf
sbin/nginx