Technology Sharing

Tomcat download, installation and configuration tutorial (zero basis and super detailed)

2024-07-12

한어Русский языкEnglishFrançaisIndonesianSanskrit日本語DeutschPortuguêsΕλληνικάespañolItalianoSuomalainenLatina

"About the Author":China's Cybersecurity Team for the Winter Olympics, CSDN Top 100, worked at Qi'anxin for many years, and wrote books based on practical work "Network Security Self-Study Course"It is suitable for students with weak foundation to systematically learn network security and master the most core technologies in the shortest time.

insert image description here

1. Download

Download Tomcat official website https://tomcat.apache.org/download-10.cgi

insert image description here

2. No installation required

Unzip the installation package to the specified directory. The unzipped directory should not contain Chinese characters.

insert image description here

2.1 Directory Structure

  • bin: Stores Tomcat commands. For example, startup is used to start Tomcat, and shutdown is used to shut it down..batThe end is a Windows command,.shThe end is the Linux command
  • conf: Stores Tomcat configuration files.
  • lib: Stores the jar packages that Tomcat depends on at runtime.
  • logs: Operation log. Can be cleared.
  • temp: Temporary file. Can be cleared.
  • webapps: Store development projects. When tomcat starts, it will load the applications in the webapps directory.
  • work: Stores compiled files when Tomcat is running.

3. Install Java environment

The operation of Tomcat depends on the Java environment, otherwise an error will be reported.

insert image description here
The Which version on the official website shows the Java version that each Tomcat version depends on. For example, if we use 10.1.24, we need to install a Java environment of 11 or higher.

insert image description here

arrive https://www.oracle.com/java/technologies/downloads/, select Windows version.

insert image description here

After the download is complete, double-click to install and click Next.

insert image description here

The new version of JDK will automatically configure the PATH environment variable. Open cmd and execute java -versionjavac -version, the displayed version means the installation is successful.

insert image description here

At this time, running tomcat will still report an error, saying that you do not have a JAVA_HOME variable, then we will create a new JAVA_HOME variable, the variable value is the JDK installation directory, the path one level above bin.

insert image description here

Will%JAVA_HOME%binvariable to the PATH environment variable.

insert image description here

Extension: If the environment variables cannot be saved after configuration, you can use the registry to modify the environment variables.

win + r Open the Registry Editor and findHKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlSession ManagerEnvironment. Add a string value of JAVA_HOME and add it to the leftmost of the Path data.%JAVA_HOME%bin;

insert image description here

After modifying the registry, restart the computer to make it effective.

4. Two ways to start Tomcat

1) Go to the bin directory of the Tomcat installation directory and double-click startup.dat.

insert image description here

Do not close the black window that pops up, enterhttp://127.0.0.1:8080/, if you see this cat, it means Tomcat has started successfully. Close the black window and Tomcat will stop.

insert image description here

2) Go to the bin directory of Tomcat installation, enter cmd in the address bar, open cmd in the current path, enter startup to start Tomcat. You can stop Tomcat by entering shutdown or closing the black window.

insert image description here