How do i install apache tomcat?
-
This method of installation uses, the standard download binaries a package and install. There are other method using source code.
The different version information can be found at: https://tomcat.apache.org/whichversion.html
Prerequisites.
Make sure install the correct version of Java for the version. This mean either the JRE or the JDK.
The binaries for Tomcat can be found at the main Tomcat website (under the Downloads heading): https://tomcat.apache.org/
Best to have a user called tomcat and make the directory owned by tomcat and group tomcat.
Download the binary package you need and extract them usually /usr/local or /opt.
tar xvf apache-tomcat-9.0.0.M21.tar.gz apache-tomcat-9.0.0.M21/conf/ apache-tomcat-9.0.0.M21/conf/catalina.policy apache-tomcat-9.0.0.M21/conf/catalina.properties apache-tomcat-9.0.0.M21/conf/context.xml apache-tomcat-9.0.0.M21/conf/jaspic-providers.xml apache-tomcat-9.0.0.M21/conf/jaspic-providers.xsd apache-tomcat-9.0.0.M21/conf/logging.properties apache-tomcat-9.0.0.M21/conf/server.xml apache-tomcat-9.0.0.M21/conf/tomcat-users.xml apache-tomcat-9.0.0.M21/conf/tomcat-users.xsd apache-tomcat-9.0.0.M21/conf/web.xml apache-tomcat-9.0.0.M21/bin/ apache-tomcat-9.0.0.M21/lib/ ... ... ...
Setup some environment variables.
The CATALINA_HOME environment variable should be set to the location of the
root directory of the "binary" distribution of Tomcat.The Tomcat startup scripts have some logic to set this variable
automatically if it is absent, based on the location of the startup script
in *nix and on the current directory in Windows. That logic might not work
in all circumstances, so setting the variable explicitly is recommended.The CATALINA_BASE environment variable specifies location of the root
directory of the "active configuration" of Tomcat. It is optional. It
defaults to be equal to CATALINA_HOME.Using distinct values for the CATALINA_HOME and CATALINA_BASE variables is
recommended to simplify further upgrades and maintenance. It is documented
in the "Multiple Tomcat Instances" section below.CATALINA_BASE & CATALINA_HOME are kept the same a lot of the time, especially in test environments. For this install they are kept the same, but best to have the variable set incase you want to split them later & other Tomcat variables point to it.
$ vi /home/tomcat/.bashrc
Add:
CATALINA_HOME=path_where_tomcat_binaries_are
CATALINA_BASE=path_where_tomcat_binaries_areCreate a
setenv.sh
environment file in $CATALINA_HOME/bin
Add:
export JRE_HOME=/usr/lib/jvm/java-8-openjdk-amd64/jre
export CATALINA_PID="$CATALINA_BASE/tomcat.pid"You can also add JAVA_HOME here, pointing to the jdk.
Startup Tomcat.
$ $CATALINA_HOME/bin/startup.sh Using CATALINA_BASE: /opt/apache-tomcat-9.0.0.M21 Using CATALINA_HOME: /opt/apache-tomcat-9.0.0.M21 Using CATALINA_TMPDIR: /opt/apache-tomcat-9.0.0.M21/temp Using JRE_HOME: /usr/lib/jvm/java-8-openjdk-amd64/jre Using CLASSPATH: /opt/apache-tomcat-9.0.0.M21/bin/bootstrap.jar:/opt/apache-tomcat-9.0.0.M21/bin/tomcat-juli.jar Using CATALINA_PID: /opt/apache-tomcat-9.0.0.M21/tomcat.pid Tomcat started.
Go to the browser and see if tomcat server is running on port 8080. http://localhost:8080
Stop Tomcat
$ $CATALINA_HOME/bin/shutdown.sh
© Lightnetics 2024