Apache Tomcat is a widely used Java application server with over million downloads per month. The wide success of Tomcat is due to its efficient, effective and light weight nature. Tomcat implements a servlet container and JSP, which is what majority of web applications depend on. Tomcat is not burdened by 20+ odd standards that form Java EE standard. As Apache Tomcat is not a Java EE engine, it can continue to stay light weight and meet the needs of web applications. While many other application servers came about in last decade, none have enjoyed the same level of success as Tomcat.
The current version of Apache Tomcat is 8.0 . Apache Tomcat powers numerous mission critical applications across a wide range of industries and organizations.
Apache Tomcat is used to deploy your Java Servlets and JSPs. So in your Java project you can build your WAR (short for Web ARchive) file, and just drop it in the deploy directory in Tomcat.
So basically Apache is an HTTP Server, serving HTTP. Tomcat is a Servlet and JSP Server serving Java technologies.
Tomcat is a servlet container. A servlet, at the end, is a Java class. JSP files (which are similar to PHP, and older ASP files) are generated into Java code (HttpServlet), which is then compiled to .class files by the server and executed by the Java virtual machine.
In this article I will show how to install and setup Apache Tomcat 8 on CentOS/RHEL 7 system.
Install and Setup Apache Tomcat 8
Follow the below steps to install and setup Apache Tomcat 8 CentOS/RHEL 7 machine.
1. First of all Install Oracle Java.
2. Download Apache Tomcat 8.
# cd /opt # wget http://apache.arvixe.com/tomcat/tomcat-8/v8.0.22/bin/apache-tomcat-8.0.22.tar.gz
3. Extract the downloads tar file.
# tar xzvf apache-tomcat-8.0.22.tar.gz
4. Crate user and group and add the user 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 and add the below lines.
# vim /usr/lib/systemd/system/tomcat8.service [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. Start tomcat server and make it auto start at boot time.
# systemctl start tomcat8 # systemctl enable tomcat8
8. Tomcat server works on port 8080 default. You can access from your browser using the url :
http://localhost_or_IP: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.
# vim /opt/tomcat/conf/tomcat-users.xml
Add the below lines.
<!-- 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>
If you find this tutorial helpful please share with your friends to keep it alive. For more helpful topic browse my website www.looklinux.com. To become an author at LookLinux Submit Article. Stay connected to Facebook.
Leave a Comment