Windows configuration local Tomcat server

One, install Java

Java installation can go to the Oracle official website to download the jdk installation program of jdk-8u191-windows-x64.exe. More attention should be paid to the Jdk environment configuration. Right-click Computer >> Properties >> Advanced System Settings >> Environment Settings.
Increase the system environment variables as follows:

JAVA_HOME  C:\Program Files\Java\jdk1.8.0_144 // 为 jdk 的安装路径
JRE_HOME  %JAVA_HOME%\jre
CLASSPATH  %JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\tools.jar

Modify the original PATH environment variable. And add the following content:

;%JAVA_HOME%\bin;%JRE_HOME%\bin

By the CDM input javaand javacis configured properly to test.

Two, install Tomcat

Tomcat can be downloaded from the Tomcat official website , select the required version and the corresponding number of bits. For example, we downloaded apache-tomcat-8.0.50-windows-x64.zip.

Then unzip the Zip compressed package and place it in the relevant location.

Three, configure Tomcat

You can click to run directly under the Tomcat directory startup.bat. If there is an error

D:\Tomcat\apache-tomcat-8.0.50-windows-x64\apache-tomcat-8.0.50\bin>startup.bat
The JRE_HOME environment variable is not defined correctly
This environment variable is needed to run this program

It means that Tomcat cannot correctly recognize the JDK environment in the system.

Analysis startup.batstartup script can be found. Which actually callscatalina.bat

rem Guess CATALINA_HOME if not defined
set "CURRENT_DIR=%cd%"
if not "%CATALINA_HOME%" == "" goto gotHome
set "CATALINA_HOME=%CURRENT_DIR%"

Its meaning is already obvious. There are two solutions to the above problem:

  • Adding system variables for Tomcat CATALINA_HOME
    add Tomcat environment variables to the environment variable
CATALINA_HOME  D:\Tomcat\apache-tomcat-8.0.50-windows-x64\apache-tomcat-8.0.50 
  • Or catalina.batadding the specified JAVA_HOME environment
    modify catalina.batthe file, add the following environment provided at a corresponding position
rem ---------------------------------------------------------------------------
rem Set JAVA_HOME or JRE_HOME if not already set, ensure any provided settings
rem are valid and consistent with the selected start-up options and set up the
rem endorsed directory.
rem ---------------------------------------------------------------------------

set JAVA_HOME=D:\Tomcat\apache-tomcat-8.0.50-windows-x64\apache-tomcat-8.0.50
set JRE_HOME=C:\Program Files\Java\jdk1.8.0_131\jre

test environment

Tomcat into the directory, run startup.bat, open the browser to access http://localhost:8080either see the Tomcat interface.

tomcat

Guess you like

Origin blog.csdn.net/qq_36148847/article/details/85102674