Install Apache Tomcat on OpenSUSE

In this article, we will go through how to install Apache Tomcat on OpenSUSE. 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 OpenSUSE

  • Update your system.
sudo zypper update

Install Java 18 on OpenSUSE

  • Download Java by running the command below
wget https://download.oracle.com/java/18/latest/jdk-18_linux-x64_bin.rpm
  • After downloading, install it using the following command.
sudo rpm -ivh jdk-18_linux-x64_bin.rpm

Sample output

Preparing...                                                            (1################################# [100%]
Updating / installing...
   1:jdk-18-2000:18.0.2.1-ga                                            ( ################################# [100%]
update-alternatives: using /usr/java/jdk-18.0.2.1/bin/java to provide /usr/bin/java (java) in auto mode
  • To confirm the version of Java install, run the command below.
java --version

Install Apache Tomcat on OpenSUSE

VER="10.0.23"
wget https://archive.apache.org/dist/tomcat/tomcat-10/v${VER}/bin/apache-tomcat-${VER}.tar.gz
  • Extract Apache Tomcat.
tar xvf apache-tomcat-${VER}.tar.gz
  • Move the extracted files to the /opt directory using the command below.
sudo mv apache-tomcat-${VER} /opt/tomcat
  • Next. create Apache Tomcat user.
sudo useradd -M -d /usr/share/apache-tomcat tomcat
  • Give the user permission using the following command.
sudo chown -R tomcat /opt/tomcat
  • To allow one specific IP address to access Apache Tomcat, add it to the config files below.
sudo nano /opt/tomcat/webapps/manager/META-INF/context.xml
sudo nano /uopt/tomcat/webapps/host-manager/META-INF/context.xml
  • Add your IP address such as 192.168.5.80 in the opened files above.
<Valve className="org.apache.catalina.valves.RemoteAddrValve"
         allow="127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1|192.168.5.80" />
  • Allow Tomcat to be accessed by any IP address by removing the IP address.
<Valve className="org.apache.catalina.valves.RemoteAddrValve"
         allow="127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1" />

Secure Apache Tomcat on OpenSUSE

  • Open the users’ config file.
sudo nano /opt/tomcat/conf/tomcat-users.xml

Add the config below above </tomcat-users> . Replace YourStrongPassword with your real password.






Configure Systemd for Apache Tomcat

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

Paste the code below.

[Unit]
Description=Apache Tomcat 10 Web Application Container
Wants=network.target
After=network.target

[Service]
Type=forking

Environment="JAVA_OPTS=-Djava.awt.headless=true -Djava.security.egd=file:///dev/urandom"
Environment="CATALINA_BASE=/opt/tomcat"
Environment="CATALINA_HOME=/opt/tomcat"
Environment="CATALINA_TMPDIR=/opt/tomcat/temp"
Environment="CATALINA_OPTS=-Xms512M -Xmx1024M -server -XX:+UseParallelGC"

ExecStart=/opt/tomcat/bin/startup.sh
ExecStop=/opt/tomcat/bin/shutdown.sh

[Install]
WantedBy=multi-user.target
  • Reload systemd daemon using the command below
sudo systemctl daemon-reload
  • Restart Tomcat.
sudo systemctl restart tomcat
  • Enable tomcat to run on system boot.
sudo systemctl enable tomcat

Access Apache Tomcat Web

  • Fire up your web browser and enter your IP address followed by port 8080 e.g. 192.168.5.40:8080
Install Apache Tomcat on OpenSUSE
Install Apache Tomcat on OpenSUSE
  • Click on the Manager app as shown below and enter your username and password to login into the Manager app.
Install Apache Tomcat on OpenSUSE
Install Apache Tomcat on OpenSUSE
  • Manager app dashboard.
Install Apache Tomcat on OpenSUSE
Install Apache Tomcat on OpenSUSE
  • You have made it to the end of our article, we have gone through how to install Apache Tomcat on OpenSUSE.

Read more on Apache Tomcat Documentation

Other Tutorials

Install Lighttpd on Ubuntu 22.04

Install Nodejs on Rocky Linux 9

Install LAMP Stack on Rocky Linux 9

System administrator | Software Developer | DevOps

Leave a Comment