Introduction: A Beginner’s Guide How to Install Tomcat 9 on CentOS
Apache Tomcat is a popular web server and servlet container that allows you to run Java web applications. If you’re an amateur user looking to install Tomcat 9 on CentOS, this step-by-step guide will walk you through the process. By following these instructions, you’ll have Tomcat up and running, enabling you to deploy and manage your Java web applications with ease.
Before you begin the installation process, ensure that you have the following prerequisites in place:
- A CentOS server (preferably the latest version) with root access or a user with sudo privileges.
- Java Development Kit (JDK) installed on your system. Tomcat requires Java to run.
Now, let’s dive into the installation process.
Step 1: Update System Packages
Start by updating your CentOS server’s packages to their latest versions:
sudo yum update
Step 2: Install Java Development Kit (JDK)
Tomcat requires Java to run. Install the JDK using the following command:
sudo yum install java-1.8.0-openjdk-devel
Verify the installation by running the following command:
You should see the Java version information displayed.
Step 3: Download and Extract Tomcat
Visit the Apache Tomcat download page (https://tomcat.apache.org/download-90.cgi) and copy the link address for the latest stable release of Tomcat 9. Then, on your CentOS server, change to the directory where you want to install Tomcat and download the TAR.GZ file using the
cd /opt sudo wget <paste the copied link address here>
<paste the copied link address here> with the link address, you copied from the Tomcat download page.
Extract the downloaded TAR.GZ file using the following command:
sudo tar -xvf apache-tomcat-9*.tar.gz
Step 4: Configure Environment Variables
To use Tomcat from anywhere in the system, you need to configure the environment variables. Open the
.bashrc file in a text editor:
sudo nano ~/.bashrc
Add the following lines at the end of the file:
export CATALINA_HOME=/opt/apache-tomcat-9.x.x export PATH=$PATH:$CATALINA_HOME/bin
9.x.x with the specific version number of Tomcat you downloaded.
Save the file and exit the text editor.
To apply the changes, run the following command:
Step 5: Start Tomcat
Start Tomcat using the following command:
Step 6: Access Tomcat Web Interface
You can now access the Tomcat web interface by visiting your server’s IP address or domain name in your web browser:
You’ll be greeted with the Tomcat welcome page, indicating that Tomcat is running successfully.
Congratulations! You have successfully installed Tomcat 9 on your CentOS server. By following the steps outlined in this guide, you can now deploy and manage your Java web applications using Tomcat. Take advantage of the features and capabilities offered by Tomcat to host and run your Java-based websites and applications with efficiency.
- Apache Tomcat Official Website: https://tomcat.apache.org/
- CentOS Official Website: https://www.centos.org/
- Java SE Development Kit (JDK) Official Website: https://www.oracle.com/java/technologies/javase-jdk8-downloads.html