nginx + tomcat7 load balancing under mac

WBOY
Release: 2016-08-08 09:24:08
Original
1086 people have browsed it

1.tomcat installation:

Go to tomcat official website: http://tomcat.apache.org/download-70.cgi to download your version

Extract to the specified directory:

localhost:tomcat rolin$ pwd

/Users/rolin/soft/tomcat #My directory

Copy:

localhost:tomcat rolin$ ll

total 0

drw xr-xr-x configuration file Content:

in conf/server.xml

localhost:tomcat rolin$ cat apache-tomcat-7.0.62-1/conf/server.xml

"

"Type =" Org.apache.catalina.userdatabase "

Description =" User DataBase that Can Be Updated and Saved "

" ORG.APACHE.CATALINA.USERS.MEM OverdatabaseFactory "

E PathName = "Conf/Tomcat-sses.xml"/& GT;

& LT;/GlobalNamingResources & GT;

& LT; Service name = "calyina" & gt;

& lt; Port = "8081" Protocol = "HTTP/1.1"

ConnectionTimeout = "20000"

Redirectport = "8444"/& GT;

& LT; Connector port = "8010" propocol = "AJP/ 1.3" redirectPort="8444" />


;

                                                                     < m>

Unpackwars = "TRUE" AutodePlay = "TRUE" & GT;

& LT; Valve className = "ORG.APACHE.CATALINA.Valves. Accesslogvalve "Directory =" Logs " "

< /Host> cat-7.0.62-2 /conf/server.xml

 

 

 

 

 

 

 

 

 

 


 

 

   

   

              type="org.apache.catalina.UserDatabase"

              description="User database that can be updated and saved"

              factory="org.apache.catalina.users.MemoryUserDatabaseFactory"

              pathname="conf/tomcat-users.xml" />

 


 

 


   

   



   

               connectionTimeout="20000"

               redirectPort="8443" />

   



   


   

   


     

     


     

     

       

       

               resourceName="UserDatabase"/>

     


     

            unpackWARs="true" autoDeploy="true">


       

       


       

       

               prefix="localhost_access_log." suffix=".txt"

               pattern="%h %l %u %t "%r" %s %b" />


                                                                                   

./apache-tomcat-7.0. 62-1/bin/startup.sh

./apache-tomcat-7.0.62-2/bin/startup.sh

Address:

http://localhost:8081/

If the cat appears, it is correct.

2.nginx installation:

On Mac, it is installed using brew


brew: Installation requires sudo permission

curl -LsSf http://github.com/mxcl/homebrew/tarball/master | sudo tar xvz -C/usr/local --strip 1

nginx installation command:

brew install nginx

View version

nginx -V


nginx Configuration


localhost:tomcat rolin$ cat /usr/local/etc/nginx/nginx.conf

# user nobody; worker_processes 2;


#error_log logs/error.log;

#error_log logs/error.log notice;

#error_log logs/error.log info;


#pid logs/nginx.pid;


1024;

}



http {

include mime.types;

default_type application/octet-stream;


#log_format main '$remote_addr - $remote_user [$time_local] " $request" '

'"

#access_log logs/access. log main;


sendfile on;

#tcp_nopush on;


#keepalive_timeout 0;

keepalive_timeout 65;


  #gzip on;


upstream localhost{ #Configure our tomcat address here

                                               host:8081;

server localhost:8082 ;

}

server {

80; # charset koi8-r;

        charset utf-8;


        #access_log  logs/host.access.log  main;


        location / {

            root   html;

            index  index.html index.htm;

            proxy_pass http://localhost;

            proxy_set_header X-Real-IP $remote_addr;

            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

            proxy_redirect HOST default;

        }


        #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                                                                                                                      

      #                                                                         index, index.html index.htm;


                          #}

}

include servers/*;

sudo nginx




Visit

Browser address bar: http://localhost/

Close nginx service
sudo nginx -s stop

The above introduces nginx + tomcat7 load balancing under mac, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template