`

Nginx+Tomcat 负载

 
阅读更多

Nginx+Tomcat 负载

1. tomcat 中文件的配置 跟 tomcat + terracotta 中的配置 一样 ,见另一文档 。

2. 下载 ngixn 1.1.7 见附件 已提供。

3. 修改 nginx-1.1.7\conf \  nginx.conf 可以整个替换为:

#user  nobody;
worker_processes  1;

error_log  logs/error.log;

events {
    worker_connections  2048;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    sendfile        on;
    keepalive_timeout  65;

    #gzip  on;
    upstream  localhost   {
              server   135.192.36.121:8888;
              server   135.192.36.122:8888;

              server   135.192.36.122:9999;

              server   135.192.36.122:9999;
    }
    server {
        listen       80;
        server_name  localhost;
        charset utf-8;
        location / {
            root   html;
            index  index.html index.htm ;
            proxy_pass        http://localhost;
            proxy_set_header  X-Real-IP  $remote_addr;
            client_max_body_size  100m;
        }


        location ~ ^/(WEB-INF)/ {
     deny all;
        }

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

    }
}

说明:

  

将localhost  替换成你的域名  或本机的 IP地址

server  后的 IP: host  是指远程机的 上如 在 tomcat 上部署的 ngrm 项目 的访问IP+端口,如远程上有

http://135.192.36.121:8888/ngrm   

http://135.192.36.121:9999/ngrm  等  。

worker_connections   : 是最大的可连接数 。

以上是最简的配置。

 

nginx 的启动:

1. 经过配置完后,用  nginx  -t  来查看是否修改正确。

 

说明 修改 nginx.conf 文件成功 。

查看 参数用 nginx  -h

 

启动 用:nginx .

 

这里用 ctrl +C 是结束不掉了,在你的  任务管理器中,能看到有 nginx 的进程 。

停止服务, 再启一个CMD ,用 nginx  -s  stop 

 

参考:

 http://ari.iteye.com/blog/833153

http://www.iteye.com/topic/676347

http://www.blogjava.net/niumd/archive/2011/05/10/349958.html

  • 大小: 47.4 KB
  • 大小: 41.9 KB
  • 大小: 62.2 KB
  • 大小: 66.3 KB
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics