Tomcat is an open-source implementation of the Java Servlet, JavaServer Pages, Java Expression Language, and Java WebSocket technologies.
The user you are logging in as must have sudo privileges to be able to install packages.
Install Java by typing the following command:
sudo yum install java-1.8.0-openjdk-devel
Create Tomcat system user
Navigate to the
/tmp directory and download the Tomcat zip file using the following wget command :
When the download is complete, extract the tar file :
tar -xf apache-tomcat-9.0.46.tar.gz
Run the following command to change the directory ownership to user and group tomcat:
Make the scripts inside the
bin directory executable by issuing the following
sudo sh -c 'chmod +x /opt/tomcat/latest/bin/*.sh'
Create a systemd unit file
sudo nano /etc/systemd/system/tomcat.service
Paste the following content:
[Unit] Description=Tomcat 9 servlet container After=network.target [Service] Type=forking User=tomcat Group=tomcat Environment="JAVA_HOME=/usr/lib/jvm/jre" Environment="JAVA_OPTS=-Djava.security.egd=file:///dev/urandom" Environment="CATALINA_BASE=/opt/tomcat/latest" Environment="CATALINA_HOME=/opt/tomcat/latest" Environment="CATALINA_PID=/opt/tomcat/latest/temp/tomcat.pid" Environment="CATALINA_OPTS=-Xms512M -Xmx1024M -server -XX:+UseParallelGC" ExecStart=/opt/tomcat/latest/bin/startup.sh ExecStop=/opt/tomcat/latest/bin/shutdown.sh [Install] WantedBy=multi-user.target
Save and close the file.
Notify systemd that we created a new unit file by typing:
sudo systemctl daemon-reload
Enable and start the Tomcat service:
Check the service status with the following command:
sudo systemctl status tomcat
● tomcat.service - Tomcat 9 servlet container Loaded: loaded (/etc/systemd/system/tomcat.service; enabled; vendor preset: disabled) Active: active (running) since Thu 2021-05-15 20:47:50 UTC; 4s ago Process: 1759 ExecStart=/opt/tomcat/latest/bin/startup.sh (code=exited, status=0/SUCCESS) Main PID: 1767 (java) CGroup: /system.slice/tomcat.service
Configure Tomcat Web Management Interface
At this point Tomcat is installed, and we can access it with a web browser on port
Once done, restart the Tomcat service for changes to take effect:
sudo systemctl restart tomcat
Test the Installation
Open your browser and type:
Upon successful installation, a screen similar to the following should appear:
Tomcat web application manager dashboard is available Now at http://<your_domain_or_IP_address>:8080