美文网首页
虚拟机+nginx+2个tomcat 负载均衡

虚拟机+nginx+2个tomcat 负载均衡

作者: 銗誨 | 来源:发表于2018-10-31 11:13 被阅读0次

一、环境以及最终效果图

centos7 192.168.25.132

windows 192.168.10.1

tomcat1 端口18080

tomca2端口28080

最终效果图

二、在centos7中Nginx安装

1.安装依赖

yum -y install make zlib zlib-devel gcc-c++ libtool openssl openssl-devel

2.配置nginx安装源

vim /etc/yum.repos.d/nginx.repo 

<span style="white-space:pre"> </span>[nginx]

name=nginx repo 

baseurl=http://nginx.org/packages/centos/7/$basearch/ 

gpgcheck=0 

enabled=1

yum install nginx

3.其他命令

查看安装目录

rpm -ql ngnix

4.配置nginx

修改如图1

vim /etc/nginx/conf.d/default.conf

修改后进入/usr/sbin重启nginx服务

./nginx -s reload

1

三、tomcat安装部署

1.安装

2个解压版tomcat 8.5

进入bin目录打开cmd进行服务注册

service

server.bat install tomcat1(名字随便取)

开启服务:我的电脑-->管理-->服务

2.部署

tomcat安装目录下打开 /conf/server.xml

修改 port参数

修改后记得重启tomcat服务

2 3 4

四、问题记录

1.输入./nginx -s reload出现

nginx: [error] open() "/var/run/nginx.pid" failed (2: No such file or directory)

解决方法:进入/etc/nginx

nginx -c nginx.conf

2.关闭防火墙

停止firewall

systemctlstopfirewalld.service

禁止firewall开机启动

systemctl disable firewalld.service

相关文章

网友评论

      本文标题:虚拟机+nginx+2个tomcat 负载均衡

      本文链接:https://www.haomeiwen.com/subject/yqiotqtx.html