1.安装tomcat请参考:https://blog.csdn.net/qq_32784303/article/details/80366962
2.复制两个tomcat出来,将其中一个端口号更改(usr/local/tomcat/tomcat1/conf/service.xml)
3.启动两个tomcat
4.安装nginx:
4.1.安装make:
yum -y install gcc automake autoconf libtool make
安装g++:
yum install gcc gcc-c++
4.2:选定安装文件目录
cd /usr/local/src
4.3:安装PCRE库
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.39.tar.gz tar -zxvf pcre-8.39.tar.gz cd pcre-8.39 ./configure make make install
4.4:安装zlib库
cd /usr/local/src wget http://zlib.net/zlib-1.2.11.tar.gz tar -zxvf zlib-1.2.11.tar.gz cd zlib-1.2.11 ./configure make make install
4.5:安装openssl(某些vps默认没装ssl)
cd /usr/local/src wget https://www.openssl.org/source/openssl-1.0.1t.tar.gz tar -zxvf openssl-1.0.1t.tar.gz
4.6:安装nginx
cd /usr/local/src wget http://nginx.org/download/nginx-1.1.10.tar.gz tar -zxvf nginx-1.1.10.tar.gz cd nginx-1.1.10 ./configure make make install
这里安装如果报错
请执行:
yum -y install openssl openssl-devel
4.7:更改nginx端口号为8089
vi /usr/local/nginx/conf/nginx.conf
4.8:启动nginx
方式一:/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
方式二:/usr/local/nginx/sbin/nginx -t
查看启动的nginx端口:
netstat -ano|grep 8089
4.9:停止nginx
kill -QUIT 2072(2072为ps -ef|grep nginx查询出的nginx进程pid)
pkill -9 nginx(为强制停止)
5.配置nginx.conf实现反向代理
6.启动nginx
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
7.浏览器访问会在两个tomcat之间来回切换