版权声明:本文为博主原创文章,未经博主允许不得转载! https://blog.csdn.net/qq_39539575/article/details/83617721
一、安装tomcat
tomcat安装不做介绍,在每台服务器上都安装tomcat即可!
二、安装nginx
三、修改nginx的配置文件
yum安装后,nginx的配置文件在/etc/nginx下面
可以执行指令:
vim /etc/nginx/nginx.conf
修改为:
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
include /etc/nginx/conf.d/*.conf;
upstream 名字{
server 192.168.30.101:8080 weight=1;
server 192.168.30.102:8080 weight=3;
server 192.168.30.103:8080 weight=3;
}
server {
listen 监听端口号;
server_name 域名;
location / {
proxy_pass http://名字;
proxy_redirect default;
}
}
}
注意:upstream后面的名字要与proxy_pass的的名字对应起来。
之后在每台服务器上都启动tomcat,访问你的域名加端口号就实现nginx部署tomcat集群了!
nginx较为详细的配置请点击 ↓
-------------------------------------------------------------------------------------------------------------------
外加一个启动tomcat时实时查看日志的指令
./startup.sh | tail -f ../logs/catalina.out