Centos6.5 Nginx +Tomcat 集群搭建

前端之家收集整理的这篇文章主要介绍了Centos6.5 Nginx +Tomcat 集群搭建前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

系统资源:

Nginx 一台

Tomcat +JDK 两台


第一步:CentOs 6.5 安装Nginx 详细步骤:请参考centos 6.5 搭建nginx

第二步:CentOs6.5 安装Tomcat +JDK 详细步骤:请参考CentOs 6.5 搭建Tomcat +CentOs6.5 搭建JDK

第三步:修改Nginx配置文件,我的Nginx 配置文件位置(cd /usr/local/webserver/Nginx/Nginx.conf)

#user  nobody;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/Nginx.pid;


events {
    use epoll;
    worker_connections  1024;
}


http {
    include       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  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;
    
    upstream servers{
	server 120.25.56.93:8080;
	server 120.25.58.50:8080;  
	}
    #gzip  on;

    server {
        listen       8084;
        server_name  120.76.112.207;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
           proxy_pass  http://servers;
	   proxy_set_header Host $host;
	   proxy_set_header X-Real-IP $remote_addr;
	   proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.PHP$ {
        #    proxy_pass   http://127.0.0.1;
        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        #location ~ \.PHP$ {
        #    root           html;
        #    fastcgi_pass   127.0.0.1:9000;
        #    fastcgi_index  index.PHP;
        #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        #    include        fastcgi_params;
        #}

        # deny access to .htaccess files,if Apache's document root
        # concurs with Nginx's one
        #
        #location ~ /\.ht {
        #    deny  all;
        #}
    }


    # another virtual host using mix of IP-,name-,and port-based configuration
    #
    #server {
    #    listen       8000;
    #    listen       somename:8080;
    #    server_name  somename  alias  another.alias;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}


    # HTTPS server
    #
    #server {
    #    listen       443 ssl;
    #    server_name  localhost;

    #    ssl_certificate      cert.pem;
    #    ssl_certificate_key  cert.key;

    #    ssl_session_cache    shared:SSL:1m;
    #    ssl_session_timeout  5m;

    #    ssl_ciphers  HIGH:!aNULL:!MD5;
    #    ssl_prefer_server_ciphers  on;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}

}
第四步:重新启动ngixn
[root@iZ94phz01rnZ sbin]# ./Nginx -s reload
[root@iZ94phz01rnZ sbin]# ./Nginx -s reopen

第五步:相关效果截图:

原文链接:https://www.f2er.com/centos/382146.html

猜你在找的CentOS相关文章