Apache and tomcat are both Web web servers. They have both links and differences. In the process of HTML, PHP, JSP, Perl, and other development, you must accurately master their respective features, select the best server configuration.
Apache is a web server (static parsing, such as HTML), and Tomcat is a Java application server (Dynamic parsing, such as JSP and PHP)
Tomcat is just a servlet (JSP is also translated into servlet) container. It can be considered as an extension of Apache, but it can run independently of Apache.
The two can be compared from the following points:
1. Both are developed by Apache.
2. Both have HTTP service functions
3. Both are open-source and free.
I. Contact
1) Apache is a common server. It only supports HTML, which is a common webpage. It supports PHP through plug-ins and can also be connected to Tomcat (APACHE connects tomcat in one way, that is, Apache can access Tomcat resources, otherwise ).
2) Apache only supports static Web pages, but dynamic web pages such as ASP, JSP, PHP, and CGI must be processed by Tomcat.
3) integrated use of Apache and tomcat:
If the client requests a static page, the Apache server only needs to respond to the request;
If the client requests a dynamic page, the Tomcat server responds to the request, parses the parsed JSP and other webpage code, returns it to the Apache server, and then returns it to the browser through Apache.
This is because JSP interprets code on the server. Tomcat only performs dynamic code parsing, and Apache returns the parsed static code. Apache + Tomcat can reduce Tomcat service overhead by integrating it.
4) Apache and tomcat are independent and can be integrated on the same server.
Ii. Differences
Apache is implemented in C language and supports various features and modules to expand core functions. Tomcat is written in Java and better supports Servlet and JSP.
1. Apache is a Web server. The Web Server transfers (serves) pages so that the browser can browse them. The web server specifically processes HTTP requests ), however, application servers use many protocols to provide business logic for applications ).
Tomcat is an Application server running on Apache. The application server provides the call method (methods) that can be called by client applications ). It is just a servlet (JSP is also translated into servlet) container, which can be considered as an extension of Apache, but can run independently of Apache.
2. Apache is a common server and only supports HTML static common web pages. However, you can use the plug-in to support PHP and connect to Tomcat (one-way Apache connection to Tomcat means you can access Tomcat resources through Apache, otherwise). Tomcat is a JSP/servlet container, at the same time, it also supports HTML, JSP, ASP, PHP, CGI, etc. cgi requires some manual debugging, but it is easy.
3. Apache focuses on HTTP server, while Tomcat focuses on servlet engine. If it runs in standalone mode, Tomcat and Apache support JSP equivalent functions, but it is not ideal for static Web pages.
4. Apache can run for one year without restarting, and its stability is very good, while Tomcat does not.
5. The preferred web server is Apache, but Tomcat is used only for JSP and servlet that cannot be parsed by Apache.
6. Apache is the very first page parsing service, and Tomcat is developed later. In essence, Tomcat functions can completely replace Apache, but Apache is a predecessor of tomcat after all, many people are still using Apache on the market, so Apache will continue to exist and will not be replaced. Apache cannot parse Java, but it is faster to parse HTML.
3. Two examples:
Apache is a car that can hold some things, such as HTML, but cannot hold water. To hold water, you must have a container (bucket) instead of a truck, the bucket is tomcat.
Iv. Integration of the two:
Apache is a web server environment program. It can be used as a web server but only supports static Web pages. It does not support dynamic web pages, such as ASP, JSP, PHP, and CGI.
If you want to run JSP in Apache, you need an interpreter to execute the JSP webpage. the JSP interpreter is tomcat.
Why JDK? If JSP needs to connect to the database, JDK is required to provide a path to connect to the database. Therefore, Apache + Tomcat + JDK is required to run the JSP web server platform.
V. Benefits of integration:
If the client requests a static page, the Apache server only needs to respond to the request.
If the client requests a dynamic page, the Tomcat server responds to the request.
Because JSP is interpreted on the server side, so integration can reduce Tomcat service overhead
Source: http://www.admin10000.com/document/974.html