nginx集群tomcat配置

1、打开nginx的官网:http://nginx.org/,下载最新的稳定版本并安装。

2、安装两个tomcat放到nginx同目录下,修改端口号(service.xml)。

3、把项目放到两个tomcat下并启动tomcat

     1.1启动命令               windows             linux

       查看文件夹子目录         dir                  ls

       打开文件夹                 ———  cd ———

        启动命令                start   *.bat               ./*.sh

        停止命令                stop    *.bat             ./*.sh

4、配置nginx

修改nginx.conf文件

 upstream localhost {//服务器列表
        server localhost:8080 weight=1;//weight 给nginx代理服务器分配权重 weigth值越大,访问次数越多
        server localhost:8081 weight=1;
    }

    server {
        listen       8888;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   html;
            index  index.html index.htm index.jsp;
	    proxy_set_header Host $host:$server_port;
	    proxy_redirect   http://localhost http://localhost:8888;
	    proxy_pass http://localhost;//代理服务器
        }

        location ~ \.jsp$ {  
            proxy_pass http://localhost;  
        } 服务器列表
        server localhost:8080 weight=1;//weight 给nginx代理服务器分配权重 weigth值越大,访问次数越多
        server localhost:8081 weight=1;
    }

    server {
        listen       8888;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   html;
            index  index.html index.htm index.jsp;
	    proxy_set_header Host $host:$server_port;
	    proxy_redirect   http://localhost http://localhost:8888;
	    proxy_pass http://localhost;//代理服务器
        }

        location ~ \.jsp$ {  
            proxy_pass http://localhost;  
        } 

 

启动nginx

启动服务:start nginx
停止服务:nginx -s stop
重新加载:nginx -s reload(配置文件被修改后需要执行它)

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值