Home Backend Development PHP Tutorial nginx + tomcat7 load balancing under mac

nginx + tomcat7 load balancing under mac

Aug 08, 2016 am 09:24 AM
apache gt nbsp quot

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.

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to conduct concurrency testing and debugging in Java concurrent programming? How to conduct concurrency testing and debugging in Java concurrent programming? May 09, 2024 am 09:33 AM

Concurrency testing and debugging Concurrency testing and debugging in Java concurrent programming are crucial and the following techniques are available: Concurrency testing: Unit testing: Isolate and test a single concurrent task. Integration testing: testing the interaction between multiple concurrent tasks. Load testing: Evaluate an application's performance and scalability under heavy load. Concurrency Debugging: Breakpoints: Pause thread execution and inspect variables or execute code. Logging: Record thread events and status. Stack trace: Identify the source of the exception. Visualization tools: Monitor thread activity and resource usage.

Application of algorithms in the construction of 58 portrait platform Application of algorithms in the construction of 58 portrait platform May 09, 2024 am 09:01 AM

1. Background of the Construction of 58 Portraits Platform First of all, I would like to share with you the background of the construction of the 58 Portrait Platform. 1. The traditional thinking of the traditional profiling platform is no longer enough. Building a user profiling platform relies on data warehouse modeling capabilities to integrate data from multiple business lines to build accurate user portraits; it also requires data mining to understand user behavior, interests and needs, and provide algorithms. side capabilities; finally, it also needs to have data platform capabilities to efficiently store, query and share user profile data and provide profile services. The main difference between a self-built business profiling platform and a middle-office profiling platform is that the self-built profiling platform serves a single business line and can be customized on demand; the mid-office platform serves multiple business lines, has complex modeling, and provides more general capabilities. 2.58 User portraits of the background of Zhongtai portrait construction

How to add a server in eclipse How to add a server in eclipse May 05, 2024 pm 07:27 PM

To add a server to Eclipse, follow these steps: Create a server runtime environment Configure the server Create a server instance Select the server runtime environment Configure the server instance Start the server deployment project

How to deploy and maintain a website using PHP How to deploy and maintain a website using PHP May 03, 2024 am 08:54 AM

To successfully deploy and maintain a PHP website, you need to perform the following steps: Select a web server (such as Apache or Nginx) Install PHP Create a database and connect PHP Upload code to the server Set up domain name and DNS Monitoring website maintenance steps include updating PHP and web servers, and backing up the website , monitor error logs and update content.

How to leverage Kubernetes Operator simplifiy PHP cloud deployment? How to leverage Kubernetes Operator simplifiy PHP cloud deployment? May 06, 2024 pm 04:51 PM

KubernetesOperator simplifies PHP cloud deployment by following these steps: Install PHPOperator to interact with the Kubernetes cluster. Deploy the PHP application, declare the image and port. Manage the application using commands such as getting, describing, and viewing logs.

How to implement PHP security best practices How to implement PHP security best practices May 05, 2024 am 10:51 AM

How to Implement PHP Security Best Practices PHP is one of the most popular backend web programming languages ​​used for creating dynamic and interactive websites. However, PHP code can be vulnerable to various security vulnerabilities. Implementing security best practices is critical to protecting your web applications from these threats. Input validation Input validation is a critical first step in validating user input and preventing malicious input such as SQL injection. PHP provides a variety of input validation functions, such as filter_var() and preg_match(). Example: $username=filter_var($_POST['username'],FILTER_SANIT

Java Data Structures and Algorithms: A Practical Guide to Cloud Computing Java Data Structures and Algorithms: A Practical Guide to Cloud Computing May 09, 2024 am 08:12 AM

The use of data structures and algorithms is crucial in cloud computing for managing and processing massive amounts of data. Common data structures include arrays, lists, hash tables, trees, and graphs. Commonly used algorithms include sorting algorithms, search algorithms and graph algorithms. Leveraging the power of Java, developers can use Java collections, thread-safe data structures, and Apache Commons Collections to implement these data structures and algorithms.

What are the commonly used protocols and libraries in Java network programming? What are the commonly used protocols and libraries in Java network programming? May 09, 2024 pm 06:21 PM

Commonly used protocols and libraries for Java network programming: Protocols: TCP, UDP, HTTP, HTTPS, FTP Libraries: java.net, java.nio, ApacheHttpClient, Netty, OkHttp

See all articles