How to install Apache Tomcat
Apache Tomcat is a web server for multiple operating systems, including CentOS. It's open-source software developed by the Apache Software Foundation, so it's available for free under the Apache license. Apache Tomcat is written in Java, and uses JavaServer Pages and Java servlets to create a pure Java runtime environment. It runs as a single process in its simplest configuration, although Tomcat processes each HTTP request from the browser as a separate thread. The procedure for installing Tomcat generally involves installing the Java Development Kit (JDK), configuring the system environment, downloading Tomcat and installing it.
|DIFFICULTY||Basic - 1 | Medium - 2 | Advanced - 3|
|TIME REQUIRED||10 min|
|RELATED PRODUCTS||Linux-based VPS or dedicated servers|
Here is a quick tutorial on how to install Apache Tomcat.
NOTE: cPanel/WHM users should follow cPanel's instructions instead to use EasyApache
Install the JDK
Assume for this example that you wish to develop Java programs in addition to installing the JDK. Assume further that the current version of JDK is v1.7.0, and you want to automatically answer "yes" to all questions that the installation program asks. Enter the following command at the CentOS command line:
Set the JAVA_HOME environment variable
Set JAVA_HOME to the location of JDK, which is /usr/lib/jvm/java-1.7.0-openjdk by default.
$ source /etc/profile.d/java.sh
Download Apache Tomcat
Download the Tomcat binary. The following command assumes that the current version of Tomcat is v7.0.56:
NOTE: Always check to ensure you are downloading the latest version. Version 7.0.56 was current at the time of writing.
Unpack and configure
Unpack the binary file with the tar command:
Make the unpacked files read-only;
Set CATALINA_HOME to the directory for the Tomcat files
$ source /etc/profile.d/tomcat.sh
Run Tomcat's startup script.
Verify that Tomcat is running by going to http://localhost:8080 in your browser. This URL should appear as follows:
Change your Tomcat login credentials
You'll also need to update the password you use to log in to your Tomcat Manager. We've got thos instructions for you here.