Install Apache Tomcat on Fedora 36

This guide will take you through how to install Apache Tomcat on Fedora 36. The Apache Tomcat software is an open-source implementation of the Jakarta Servlet, Jakarta Server Pages, Jakarta Expression Language, Jakarta WebSocket, Jakarta Annotations and Jakarta Authentication specifications.

How to Install Apache Tomcat on Fedora 36

  • Update Fedora 36 using the command below.
sudo dnf update

Install Java 18 on Fedora 36

  • Install Java using the command below.
sudo dnf install -y java-18-openjdk

Sample output

Dependencies resolved.
==============================================================================
 Package                     Arch   Version                     Repo     Size
==============================================================================
Installing:
 java-latest-openjdk         x86_64 1:18.0.2.0.9-1.rolling.fc36 updates 240 k
Installing dependencies:
 java-latest-openjdk-headless
                             x86_64 1:18.0.2.0.9-1.rolling.fc36 updates  40 M
 mkfontscale                 x86_64 1.2.1-4.fc36                fedora   32 k
 ttmkfdir                    x86_64 3.0.9-65.fc36               fedora   54 k
 xorg-x11-fonts-Type1        noarch 7.5-33.fc36                 fedora  500 k

Transaction Summary
==============================================================================
Install  5 Packages

Total download size: 41 M
Installed size: 190 M
Downloading Packages:

Download Apache Tomcat on Fedora 36

VER="10.0.23"
wget https://archive.apache.org/dist/tomcat/tomcat-10/v${VER}/bin/apache-tomcat-${VER}.tar.gz
  • Next, extract Apache Tomcat using the command below.
tar xvf apache-tomcat-${VER}.tar.gz
  • Then move the extracted files to the /usr/libexec/tomcat directory.
sudo mv apache-tomcat-${VER} /usr/libexec/tomcat
  • Create an Apache Tomcat group using the command below.
sudo groupadd --system tomcat
  • After creating a group, create a Tomcat user using the following command.
sudo useradd -M -d /usr/libexec/tomcat -g tomcat tomcat
  • Give the user permission for the installation directory.
sudo chown -R tomcat:tomcat /usr/libexec/tomcat

Disable SELinux on Fedora 36

  • Run the commands below to put DeLinux in permissive mode.
sudo setenforce 0
sudo sed -i 's/^SELINUX=.*/SELINUX=permissive/g' /etc/selinux/config
  • You can also disable it permanently using the following commands.
sudo sed -i 's/^SELINUX=.*/SELINUX=disabled/g' /etc/selinux/config
sudo reboot

Apache Tomcat systemd service

  • Create Apache Tomcat systemd service file.
sudo nano /etc/systemd/system/tomcat.service

Copy and paste the code below.

[Unit]
Description=Apache Tomcat 
Documentation=http://tomcat.apache.org/tomcat.0-doc/
After=network.target syslog.target

[Service]
User=tomcat
Group=tomcat
Type=oneshot
ExecStart=/usr/libexec/tomcat/bin/startup.sh
ExecStop=/usr/libexec/tomcat/bin/shutdown.sh
RemainAfterExit=yes
[Install]
WantedBy=multi-user.target
  • Reload system daemon.
sudo systemctl daemon-reload
  • Then enable Apache Tomcat to run on boot system boot using the command below.
sudo systemctl enable tomcat
  • Next, start Apache Tomcat.
sudo systemctl start tomcat
  • Check Tomcat status.
systemctl status status tomcat

Sample output

● tomcat.service - Apache Tomcat
     Loaded: loaded (/etc/systemd/system/tomcat.service; enabled; vendor preset: disabled)
     Active: active (exited) since Wed 2022-08-31 15:55:41 EAT; 14s ago
       Docs: http://tomcat.apache.org/tomcat.0-doc/
    Process: 18052 ExecStart=/usr/libexec/tomcat/bin/startup.sh (code=exited, status=0/SUCCESS)
   Main PID: 18052 (code=exited, status=0/SUCCESS)
      Tasks: 30 (limit: 4629)
     Memory: 145.2M
        CPU: 4.219s
     CGroup: /system.slice/tomcat.service
             └─ 18066 /usr/bin/java -Djava.util.logging.config.file=/usr/libexec/tomcat/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djdk.tls.ephemeralDHKeySize=2048 -Djava.protocol.handler.p>

Aug 31 15:55:41 fedora systemd[1]: Starting tomcat.service - Apache Tomcat...
Aug 31 15:55:41 fedora startup.sh[18052]: Tomcat started.
Aug 31 15:55:41 fedora systemd[1]: Finished tomcat.service - Apache Tomcat.

Allow Apache Tomcat on your firewall

  • Add Apache Tomcat to your firewall using the following command.
sudo firewall-cmd --add-port=8080/tcp
  • Then reload the firewall to apply changes.
sudo firewall-cmd --reload

Configure Apache Tomcat Web Interface

  • Open the Tomcat users configuration file.
sudo nano /usr/libexec/tomcat/conf/tomcat-users.xml

Between Tomcat users add the content below and change YourStrong Password with your preferred password.

  
  
  
  • Restart Apache Tomcat.
sudo systemctl restart tomcat

Access Tomcat Web

  • Open your proffered web browser and enter your IP address followed by port 8080 e.g. http://192.168.0.5:8080
Install Apache Tomcat on Fedora 36
Install Apache Tomcat on Fedora 36
  • Access the manager by clicking on the manager app. Enter the username and password that were set above.
Install Apache Tomcat on Fedora 36
Install Apache Tomcat on Fedora 36
  • After signing in, you will be able to access the dashboard as shown below.
Install Apache Tomcat on Fedora 36
Install Apache Tomcat on Fedora 36
  • You have reached the end of our tutorial, we have gone through how to install Apache Tomcat on Fedora 36.

Read more on Apache Tomcat Documentation

Other Tutorials

Install Ubuntu Mate 22.04 LTS on VirtualBox

Install Rocky Linux 9 on VirtualBox

Install VirtualBox Guest Additions on Rock Linux 9

System administrator | Software Developer | DevOps

Leave a Comment