This is the fourth day of my participation in the November Gwen Challenge. See details: The last Gwen Challenge 2021.

Up to now, web server has rarely been mentioned in companies or projects. As for the reason, the author himself has no way of knowing, except that at the beginning of his contact with OA system of government institutions, he knows that there are Tomcat, Weblogic, JBoss, etc. Sometimes it's hard to distinguish them from web servers like Apache and Nginx

I. Introduction to Tomcat

Tomcat is a core project of the Apache Software Foundation’s Jakarta project, developed by Apache, Sun, and other companies and individuals. With Sun’s involvement and support, the latest Servlet and JSP specifications are always present in Tomcat, and Tomcat 5 supports the latest Servlet 2.4 and JSP 2.0 specifications. Because of its advanced technology, stable performance, and free, Tomcat is deeply loved by Java enthusiasts and recognized by some software developers, and has become a popular Web application server.

Tomcat server is a free open source Web application server, belongs to lightweight application server, in small and medium-sized systems and concurrent access users are not many occasions is widely used, is the first choice for developing and debugging JSP programs. For starters, you can assume that when the Apache server is configured on a machine, you can use it to respond to requests for HTML (an application in standard Common Markup Language) pages. Tomcat is actually an extension of the Apache server, but at runtime it runs on its own, so when you run Tomcat, it actually runs as a separate process from Apache.

The trick is that, when configured correctly, Apache serves HTML pages, while Tomcat actually runs JSP pages and servlets. In addition, Tomcat, like Web servers such as IIS, has the ability to process HTML pages, and it is also a Servlet and JSP container. A separate Servlet container is the default mode of Tomcat. However, Tomcat does not handle static HTML as well as the Apache server. ———– source: Baidu Encyclopedia

1.1. Catalog Introduction
  • /bin: stores scripts for starting and stopping Tomcat on Windows or Linux
  • /conf: Stores the global configuration files of the Tomcat server, the most important of which are server.xml and web.xml
  • /doc: Stores Tomcat documents
  • /server: contains three subdirectories: classes, lib, and webapps
  • /server/lib: stores JAR files required by the Tomcat server
  • /server/webapps: stores the admin and Manager WEB applications of Tomcat
  • /common/lib: Stores jar files accessible by the Tomcat server and all Web applications
  • /shared/lib: Jar files accessible to all Web applications (but not to the Tomcat server)
  • /logs: Stores log files during Tomcat execution
  • / SRC: Stores the Tomcat source code
  • /webapps: Tomcat’s main Web publishing directory. By default, Web application files are stored in this directory
  • /work: Store the class file generated after JSP compilation

Conclusion Tomcat is an application server and container. Nginx is the Web server

2. Deploy the Tomcat server

Tomcat download address is attached; The original tomcat7.x download page has been removed from the official website, and only tomcat8.x will start

2.1 decompress Tomcat to start the service

After installing the JRE environment first, decompress the binary Tomcat installation file, go to the %CATALINA_HOME%/bin directory, and start startup.sh.

Visit the address: http://localhost:8080, you can open the following screen, the premise is that webapps have ROOT directory…

2.2. Configuration Examples

Conf /server. XML file to find the following configuration and modify port

<Connector port="8080"    maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
enableLookups="False" redirectPort="8443" acceptCount="100"  debug="0" connectionTimeout="20000"  disableUploadTimeout="True" />
Copy the code

Modify tomcat-users. XML to add roles and users. Roles can be separated by commas (,). Directories manager and ROOT indicate the ROOT directory for managing the Web page

<role rolename="admin"/>
<role rolename="manager"/>
<role rolename="manager-gui"/>
<role rolename="admin-gui"/>
<user username="tomcat" password="tomcat" roles="admin,manager,manager-gui,admin-gui"/>
Copy the code

Click Server Status and Manager APP to require account password, otherwise the page will jump as follows:

The Tomcat management page is as follows:

Third, summary

Question 1: Is Tomcat easy to deploy? If you have the JDK by default, tomcat is just decompressed to start.

Second question: in the second type, why is the status check enabled?

First of all, this is for learning, so beginners how to locate the performance bottleneck, this needs to be guided, hence the operation.

Third question: How do YOU deploy the service?

In fact, as mentioned above, everyone needs the ability to think independently; Dump the WAR package to the Tomcat/Webapps directory and start the service