Apache Tomcat is an open-source implementation of the Java Servlet, JavaServer Pages, Java Expression Language and WebSocket technologies.
See the instructions for installing Apache Tomcat on CentOS, Ubuntu & Debian below.
Prerequisites
- Open port 8080 in the firewall if installed.
Installation in CentOS 7/8
Install tomcat on your server by using the below command.
# yum install tomcat
There are several additional packages that many users, particularly those who are new to Tomcat, will find useful. Install them with the following command and this will install the Tomcat root webpage (tomcat-webapps), the web admin manager (tomcat-admin-webapps) and the official Tomcat documentation files (tomcat-docs-webapp and tomcat-javadoc).
# yum install tomcat-webapps tomcat-admin-webapps tomcat-docs-webapp tomcat-javadoc
If you are running the Apache, please stop and start the tomcat. You can use the below commands.
# systemctl stop httpd
# systemctl start tomcat
You can verify that Tomcat is running by visiting the URL http://example.com/IPaddress:8080
You will get the below page.
Installation in Ubuntu / Debian
The first thing you will want to do is update your apt-get package lists.
# apt-get update
Run the below command to install Tomcat9 on your ubuntu server.
# apt-get install tomcat9
Edit the below file /etc/default/tomcat9 to change Java options that Tomcat uses when it starts.
# vi /etc/default/tomcat9
Find the JAVA_OPTS
line and replace it with the following.
# JAVA_OPTS="-Djava.security.egd=file:/dev/./urandom -Djava.awt.headless=true -Xmx512m –XX:MaxPermSize=256m -XX:+UseConcMarkSweepGC"
Save and exit.
Restart Tomcat with this command:
# service tomcat9 restart
Now you can access the default splash page by going to your domain or IP address followed by :8080
in a web browser.
You will get the page like below.
Related Tutorials