1.Nginx的配置和安裝
https://www.cnblogs.com/zhoading/p/8514050.html
2.安裝多個Tomcat
你可以把webapps目錄里ROOT下的index.jsp改下,好看到tomcat有沒有切換
https://www.linuxidc.com/Linux/2018-02/151085.htm
3.nginx的配置 /usr/local/nginx/conf/nginx.conf
# http里面,server外面
upstream tomcat{
#輪流
server 127.0.0.1:8080;
server 127.0.0.1:8081;
server 127.0.0.1:8082;
}
server{
# 其他的省略
listen 80;
server_name localhost;
location / {
root html;
index index.html index.htm;
proxy_pass http://tomcat;
}
}
4.最后啟動nginx和tomcat,在瀏覽器里輸入localhost:80
5.如果你修改了server_name,那么你需要到/etc/hosts文件里添加你的server_name和ip
加入我把server_name改成www.123.com那么我需要在hosts文件里加入127.0.0.1 www.123.com