Need Assistance?

In only two hours, with an average response time of 15 minutes, our expert will have your problem sorted out.

Server Trouble?

For a single, all-inclusive fee, we guarantee the continuous reliability, safety, and blazing speed of your servers.

How To Install Apache Tomcat 10.0.20 on Ubuntu

How to Install Apache Tomcat 10.0.20 on Ubuntu with Apache Proxy Integration. In this guide, we walk through the process to Install Apache Tomcat 10.0.20 on Ubuntu server. We’ll also configure Apache HTTPD as a reverse proxy to route traffic from port 80 to Tomcat’s default port 8080.

Create the Tomcat User

useradd -m -d /opt/tomcat -U -s /bin/false tomcat

Install Java

cd /tmp
wget https://archive.apache.org/dist/tomcat/tomcat-10/v10.0.20/bin/apache-tomcat-10.0.20.tar.gz
tar xzvf apache-tomcat-10*tar.gz -C /opt/tomcat --strip-components=1

Set Permissions

chown -R tomcat:tomcat /opt/tomcat/
chmod -R u+x /opt/tomcat/bin

Configure Users and Roles

Edit the Tomcat users configuration file:

vim /opt/tomcat/conf/tomcat-users.xml

Add the following:

<role rolename="manager-gui" />
<user username="manager" password="manager_password" roles="manager-gui" />

<role rolename="admin-gui" />
<user username="admin" password="admin_password" roles="manager-gui,admin-gui" />

Allow Remote Access to Manager App

vim /opt/tomcat/webapps/manager/META-INF/context.xml

Edit the contents:

<Context antiResourceLocking="false" privileged="true" >
  <CookieProcessor className="org.apache.tomcat.util.http.Rfc6265CookieProcessor"
                   sameSiteCookies="strict" />
<!--  <Valve className="org.apache.catalina.valves.RemoteAddrValve"
         allow="127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1" /> -->
  <Manager sessionAttributeValueClassNameFilter="java\.lang\.(?:Boolean|Integer|Long|Number|String)|org\.apache\.catalina\.filters\.Csr>
</Context>

 Check Java Alternatives

update-java-alternatives -l

Create Systemd Service for Tomcat

vim /etc/systemd/system/tomcat.service

Paste the following:

[Unit]

Description=Tomcat

After=network.targe

[Service]

Type=forking

User=tomcat

Group=tomcat

Environment=”JAVA_HOME=/usr/lib/jvm/java-1.10.0-openjdk-amd64″

Environment=”JAVA_OPTS=-Djava.security.egd=file:///dev/urandom”

Environment=”CATALINA_BASE=/opt/tomcat”

Environment=”CATALINA_HOME=/opt/tomcat”

Environment=”CATALINA_PID=/opt/tomcat/temp/tomcat.pid”

Environment=”CATALINA_OPTS=-Xms512M -Xmx1024M -server -XX:+UseParallelGC”

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

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

RestartSec=10

Restart=always

[Install]

WantedBy=multi-user.target

Reload and Start Tomcat Service

systemctl daemon-reload

systemctl start tomcat

systemctl status tomcat

Configure Apache as a Reverse Proxy

Create a proxy configuration:

vim /etc/apache2/sites-available/tomcat-proxy.conf

Add the following:

<VirtualHost *:80>

    ServerName ip_address

    ProxyPreserveHost On

    ProxyPass / http://localhost:8080/

    ProxyPassReverse / http://localhost:8080/

    ErrorLog ${APACHE_LOG_DIR}/tomcat_error.log

    CustomLog ${APACHE_LOG_DIR}/tomcat_access.log combined

</VirtualHost>

Replace ip_address with your server’s IP or domain name.

 Conclusion

You now have Apache Tomcat 10.0.20 running under a dedicated tomcat user, managed by systemd, and served via Apache HTTPD on port 80 using a reverse proxy. This setup is robust, secure, and suitable for production environments with minor tweaks. Let me know if you’d like this blog exported as a Markdown file or formatted for a specific platform like Medium, GitHub, or Confluence.

If you encounter any issues or need expert assistance during the setup, don’t hesitate to reach out. Our team specializes in Linux server management and can help you install Apache Tomcat 10.0.20 on Ubuntu quickly and securely. Contact us today for reliable support and hassle-free server configuration!






Liked!! Share the post.

Get Support right now!

Start server management with our 24x7 monitoring and active support team

Let us know your requirement.

Can't get what you are looking for?

Get Support Right Away!

Thank You

We have received your query and will get back to you soon.