Apache Tomcat (or simply Tomcat, formerly also Jakarta Tomcat) is an open source web server and servlet container developed by the Apache Software Foundation (ASF). Tomcat implements the Java Servlet and the JavaServer Pages (JSP) specifications from Sun Microsystems, and provides a “pure Java” HTTP web server environment for Java code to run in. In the simplest config Tomcat runs in a single operating system process. The process runs a Java virtual machine (JVM). Every single HTTP request from a browser to Tomcat is processed in the Tomcat process in a separate thread.
In this tutorial we will show you how to install Tomcat 8 on CentOS/RHEL servers. We will be using a using CentOS 6.5 VPS and we will install Apache tomcat 8.0.8.
Step 1: Check JAVA version
The first requirement for a successful Tomcat 8 installation is JAVA. Make sure you have JAVA SE 7 or Later version (we will install JAVA 8) installed in your system. You can use following command to check if you have JAVA installed already on your system.
and if you get something as:
java version "1.8.0" Java(TM) SE Runtime Environment (build 1.8.0-b132) Java HotSpot(TM) Client VM (build 25.0-b70, mixed mode)
means that JAVA is installed. If you get the following message:
[[email protected] ~]# java --version -bash: java: command not found
means JAVA is not installed. You can see how to install JAVA here.
Once JAVA is installed we can continue with the tomcat installation.
Step 2: Apache Tomcat installation
First we will need to create a regular system user which will run the Tomcat server:
useradd -r tomcat808 --shell /bin/false
Download the latest Tomcat 8 version or use the following command to download Tomcat 8.0.8
Extract the contents of the downloaded archive to /opt using the following command:
tar -zxf /tmp/apache-tomcat-8.0.8.tar.gz -C /opt ln -s /opt/apache-tomcat-8.0.8 /opt/tomcat-latest chown -hR tomcat808: /opt/tomcat-latest /opt/apache-tomcat-8.0.8
Step 3: Start Apache Tomcat
The last thing that we need to create is a simple start/stop script which will start and stop our Apache Tomcat service. You can do that with the following commands:
wget -P /etc/init.d/ http://blog.mylinuxvps.com/tomcat808 /etc/init.d/tomcat808
and start the service with:
To access your newly installed Tomcat start your browser and open http://YOUR_IP:8080