What is Tomcat Server and What is Apache Tomcat used for ?
Apache Tomcat version 8 is an open source web server and servlet container developed by the Apache Software Foundation (ASF).
It provides a web server environment for Java based source code and used to deploy Java Servlets and JSPs.
Basically Apache is an HTTP Server, serving HTTP. Tomcat is a Servlet and JSP Server serving Java technologies.
Tomcat 8 is the first Apache Tomcat release to support the Servlet 3.1, JSP 2.3, EL 2.3, and WebSocket specifications.
This article will describes how to install and configure Tomcat 8 on CentOS 7, RHEL 7 and Oracle Linux 7.
1. Install Oracle java :
2. How to download Apache Tomcat 8 :
To download Apache tomcat 8, go to the apache tomcat mirror
# cd /opt # wget http://apache.arvixe.com/tomcat/tomcat-8/v8.0.22/bin/apache-tomcat-8.0.22.tar.gz
3. Extract the downloaded files :
# tar xzvf apache-tomcat-8.0.22.tar.gz
4. Create tomcat8 group and add user tomcat8 to that group:
# groupadd tomcat8 # useradd -s /bin/bash -g tomcat8 tomcat8
5. Create a symbolic link of tomcat directory to /opt/tomcat and assign permission :
# ln -s /opt/apache-tomcat-8.0.22 /opt/tomcat # chown -R tomcat8:tomcat8 /opt/tomcat /opt/apache-tomcat-8.0.22
6. Create a Systemd Setting file :
# vi /usr/lib/systemd/system/tomcat8.service
Add the following :
[Unit] Description=Apache Tomcat 8 After=network.target [Service] Type=oneshot ExecStart=/opt/tomcat/bin/startup.sh ExecStop=/opt/tomcat/bin/shutdown.sh RemainAfterExit=yes User=tomcat8 Group=tomcat8 [Install] WantedBy=multi-user.target
7. How to start tomcat server and make it auto start at boot :
# systemctl start tomcat8 # systemctl enable tomcat8
8. Tomcat server works on port 8080 default. You can access from your browser using the url :
http://serverURL:8080
9. There are changes on the user roles on Tomcat 8. By default, no users or passwords are created for the Tomcat manager roles. To set roles, user name(s) and password(s), we need to configure the tomcat-users.xml file located at $CATALINA_HOME/conf/tomcat-users.xml.
# vi /opt/tomcat/conf/tomcat-users.xml
Add the following :
<!-- user manager can access only manager section --> <role rolename="manager-gui"></role> <user username="manager" password="password" roles="manager-gui"></user> <!-- user admin can access manager and admin section both --> <role rolename="admin-gui"></role> <user username="admin" password="password" roles="manager-gui,admin-gui"></user>
Read here on the different between Apache Web Server and Apache Tomcat server.
7 Comments
Nice post. It just made my tomcat setup quick & easy and saved me few hours. Thank you.
Thanks for the useful tips and tricks! Also great blog here with all of the valuable information you have. Keep up the good work you are doing here
Thanks for sharing this article.
good post. Saved couple of hours. Thank you. Suman
Thanks for sharing
Very Good post, Thanks for the tricks
Thanks for the article.