 
  
  Apache Tomcat is a popular open-source application server used to run Java Servlet and JSP (JavaServer Pages) applications. In this guide, I will show you how to install Apache Tomcat 10 step-by-step on Ubuntu 22.04.
        
This step installs the latest packages and security patches on your system.
        
To verify the installed Java version:
      
        
If Java is not installed, you can also install OpenJDK 17 with:
      
        
        
        
Extract the downloaded archive into the 
        
Set the correct permissions for the Tomcat directory:
      
        
        
        
Save and close the file (press CTRL+X, then Y and ENTER).
        
Check that Tomcat is running:
      
        
If you see “active (running)”, Tomcat is running successfully.
        
If you're using a remote server, replace localhost with your server’s IP address or domain name:
      
        
If you're having trouble accessing the interface, you may need to open port 8080 in your firewall:
      
        
        
Add the following lines inside the file:
      
        
Save the changes and restart Tomcat:
      
        
Then, open your browser and navigate to http://localhost:8080/manager/html to log in.
        
Now Apache Tomcat is successfully running on your Ubuntu server. You can now deploy your web applications and configure Tomcat settings via the manager panel. If you encounter any issues, you can check the Tomcat logs using:
        
  
  
  
1. Update the System
First, let’s update the package manager:
          BASH
          
        
        sudo apt update && sudo apt upgrade -y
2. Install Java
Apache Tomcat requires Java, so you need to install either OpenJDK or Oracle JDK. In this example, I’ll install OpenJDK. To install OpenJDK 11 or 17, run the following command:
          BASH
          
        
        sudo apt install openjdk-11-jdk -y
          BASH
          
        
        java -version
          BASH
          
        
        sudo apt install openjdk-17-jdk -y
3. Create the Tomcat User
For security reasons, it's better to run Tomcat under a dedicated user account. Let's create a new user called tomcat:
          BASH
          
        
        sudo useradd -m -U -d /opt/tomcat -s /bin/false tomcat
4. Download Apache Tomcat
Check and download the latest version of Tomcat from the official Apache Tomcat site:
          BASH
          
        
        cd /tmp
wget https://downloads.apache.org/tomcat/tomcat-10/v10.1.39/bin/apache-tomcat-10.1.39.tar.gz
/opt/tomcat directory:
      
          BASH
          
        
        sudo mkdir -p /opt/tomcat
sudo tar -xvzf apache-tomcat-10.1.39.tar.gz -C /opt/tomcat --strip-components=1
          BASH
          
        
        sudo chown -R tomcat:tomcat /opt/tomcat
sudo chmod -R 755 /opt/tomcat
5. Start the Tomcat Service
To run Tomcat as a system service, follow these steps:- Create the service file:
          BASH
          
        
        sudo nano /etc/systemd/system/tomcat.service
- Add the following content to the file:
          INI
          
        
        [Unit]
Description=Apache Tomcat Web Application Container
After=network.target
[Service]
Type=forking
User=tomcat
Group=tomcat
Environment='JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64'
Environment='CATALINA_PID=/opt/tomcat/temp/tomcat.pid'
Environment='CATALINA_HOME=/opt/tomcat'
Environment='CATALINA_BASE=/opt/tomcat'
ExecStart=/opt/tomcat/bin/startup.sh
ExecStop=/opt/tomcat/bin/shutdown.sh
Restart=always
[Install]
WantedBy=multi-user.target
- Enable and start the Tomcat service:
          BASH
          
        
        sudo systemctl daemon-reload
sudo systemctl enable tomcat
sudo systemctl start tomcat
          BASH
          
        
        sudo systemctl status tomcat
6. Accessing the Tomcat Web Interface
By default, Tomcat runs on port 8080. To access the interface, open your browser and visit:
          PLAINTEXT
          
        
        http://localhost:8080
          PLAINTEXT
          
        
        http://your-server-ip:8080
          BASH
          
        
        sudo ufw allow 8080/tcp
7. Enabling the Tomcat Admin Panel
To access the Tomcat Manager interface, you need to define a user. Edit the following file:
          BASH
          
        
        sudo nano /opt/tomcat/conf/tomcat-users.xml
          XML
          
        
        <role rolename='manager-gui'/>
<user username='admin' password='admin123' roles='manager-gui'/>
          BASH
          
        
        sudo systemctl restart tomcat
8. Enabling Tomcat to Start Automatically
To ensure Tomcat starts automatically every time your server boots up, run the following command:
          BASH
          
        
        sudo systemctl enable tomcat
Now Apache Tomcat is successfully running on your Ubuntu server. You can now deploy your web applications and configure Tomcat settings via the manager panel. If you encounter any issues, you can check the Tomcat logs using:
          BASH
          
        
        sudo journalctl -u tomcat --no-pager | tail -n 50Related Articles
 
        
        Linux Shell – Simple Backup Script
             0 Comments          
         
        
        Useful CSF SSH Commands
             0 Comments          
        Comments ()
No comments yet. Be the first to comment!
 
         
         
     
     
     
    