Install Apache Tomcat on CentOS 7
What is Apache Tomcat
Apache Tomcat is a Java Servlet container developed by Apache to which allows you to deploy Java servlets and JSPs.
Apache Tomcat also functions as a web server, which is able to support small to medium-sized websites.
Install Apache Tomcat
It is simple to install Tomcat on CentOS server, just run the following command:
yum install tomcat
This will install Tomcat and its dependencies ( Including Java).
Now, we can install additional Tomcat packages which are useful specially for those who are new to tomcat:
yum install tomcat-webapps tomcat-admin-webapps tomcat-docs-webapp tomcat-javadoc
Tomcat-webapps: Install Tomcat root webpage.
Tomcat-admin-webapps: Install Tomcat web admin manager.
Tomcat-docs-webapp & Tomcat-javadoc: Install the official Tomcat documentaion.
Open the firewall port for the Tomcat
Tomcat by default use port 8080 which you should open it in the firewall using the following command:
> firewall-cmd --add-port=8080/tcp --permanent
> firewall-cmd --reload
Run Tomcat as a service
If your server is running Apache, you need to stop it:
systemctl stop httpd
Start Tomcat:
systemctl start tomcat
Enable Tomcat to automatically start if the server is rebooted:
systemctl enable tomcat
Now you can verify that your Apache Tomcat is working fine by visiting the URL: http://IP-Address:8080
in your browser.
Use Tomcat Web Admin Manager
In order to use Tomcat’s web management interface, you will need to create a user. Open the tomcat-users.xml
file with the command:
vi /usr/share/tomcat/conf/tomcat-users.xml
Scroll down to below the tag <tomcat-users>
and add the information for your user account:
<user username="[username]" password="[password]" roles="manager-gui,admin-gui"/>
Save and exit the file. Restart the Tomcat service for the changes to take effect:
systemctl restart tomcat
In a browser, visit the URL http://IP-Address:8080
to see the Tomcat welcome page. Click the Manager App link.
You will be prompted to log in with the username and password you created.
1 Comment
Thanks for your blog, nice to read. Do not stop.