How to Install Tomcat on an Ubuntu 20.04 Server
Tomcat is a popular web container that allows you to run Java applications on a server. This article will guide you through installing Tomcat on an Ubuntu 20.04 server.
1. Installing Java
Before installing Tomcat, ensure Java is installed on your server. Execute the following commands:
sudo apt update
sudo apt install default-jdk
2. Downloading and Installing Tomcat
Now, let’s download and install Tomcat using these commands:
cd /tmp
wget https://downloads.apache.org/tomcat/tomcat-9/v9.0.37/bin/apache-tomcat-9.0.37.tar.gz
sudo tar xzvf apache-tomcat-9.0.37.tar.gz -C /opt
sudo mv /opt/apache-tomcat-9.0.37 /opt/tomcat
sudo useradd -r -m -U -d /opt/tomcat -s /bin/false tomcat
sudo chown -R tomcat: /opt/tomcat
sudo sh -c 'chmod +x /opt/tomcat/bin/*.sh'
3. Configuring Tomcat
Now, configure Tomcat by opening the /opt/tomcat/conf/server.xml
file and editing the port Tomcat will use. This is typically port 8080. Locate the line <Connector port="8080"
and change the port if necessary.
4. Starting Tomcat
Start Tomcat using this command:
sudo /opt/tomcat/bin/startup.sh
Tomcat is now running. You can verify this by accessing http://your_server_ip:8080
in your web browser, replacing your_server_ip
with your server’s IP address.
This article showed you how to install and configure Tomcat on an Ubuntu 20.04 server. We hope you found this information helpful.