The so-called dynamic and static separation means placing static and dynamic content in web applications on different web servers, and processing dynamic and static content in a targeted manner to improve performance.
Because Tomcat is weak in concurrency and static resource processing capabilities. Separation of dynamic and static resources is one of the methods. Since Tomcat has a weak ability to process static resources, the task of processing static resources should be handed over to suitable software, and let Tomcat focus on processing JSP/Servlet requests. For the server software for static resource processing, we choose Nginx. It supports high concurrency and has strong ability to process static resources.
In fact, there are many solutions for dynamic and static separation. Some people use the combination of Apache+Tomcat; others use the combination of Tomcat+Tomcat, but the two Tomcats are placed on different hosts and different domain names. The Apache+Tomcat solution is the same in principle as the Nginx solution. They are both based on reverse proxy. Compared with using Nginx to configure dynamic and static separation, Apache's configuration is slightly more complicated.
Prerequisite: There is already a main domain name server in Tomcat+JDK environment
Set subdomain name
The IP host pointed to by the subdomain name stores static resources
Wanwang secondary domain name settings and resolution
Install Nginx
Installation The environment required by nginx, pcre (for rewrite), zlib (for compression), ssl
<code>yum -y install zlib yum –y install pcre yum –y install openssl </code>
Download and install nginx-*.tar.gz
Download nginx-1.*.tar.gz
tar –zxvf nginx-1.2.8.tar.gz –C ./
cd nginx-1.2.8
./congigure –prefix=/usr/local/nginx
make && make install
To be continued
Reference URL
Using Nginx to achieve dynamic and static separation and load balancing
CentOS+Nginx starts configuring load balancing step by step
Nginx reverse proxy and load balancing deployment guide
The above introduces the separation of dynamic and static-Nginx+Tomcat, including the content. I hope it will be helpful to friends who are interested in PHP tutorials.