How to Install Apache Tomcat 8 on CentOS 7

How to Install Apache Tomcat 8 on CentOS 7

To install Apache Tomcat 8 on CentOS 7, you can follow these steps. Apache Tomcat is an open-source Java Servlet container developed by the Apache Software Foundation.

1. Update System:

Before installing Apache Tomcat, ensure that your system packages are up to date:

sudo yum update

2. Install Java Development Kit (JDK):

Apache Tomcat requires a Java runtime environment. Install the JDK using the following command:

sudo yum install java-1.8.0-openjdk-devel

3. Download and Extract Apache Tomcat:

Visit the Apache Tomcat download page and copy the link to the latest version of Apache Tomcat 8.

Use wget to download the tar.gz file (replace <Tomcat_Version> with the actual version):

wget http://mirror.reverse.net/pub/apache/tomcat/tomcat-8/v<Tomcat_Version>/bin/apache-tomcat-<Tomcat_Version>.tar.gz

Extract the downloaded archive:

sudo tar -xf apache-tomcat-<Tomcat_Version>.tar.gz -C /opt

Create a symbolic link to make it easier to manage the Tomcat installation:

sudo ln -s /opt/apache-tomcat-<Tomcat_Version> /opt/tomcat

5. Configure Environment Variables:

Edit the ~/.bashrc file to set environment variables:

nano ~/.bashrc

Add the following lines at the end of the file:

export CATALINA_HOME="/opt/tomcat" export JAVA_HOME="/usr/lib/jvm/java-1.8.0-openjdk" export PATH="$PATH:$CATALINA_HOME/bin"

Save and close the file, then reload the bashrc:

source ~/.bashrc

6. Start Apache Tomcat:

Navigate to the Tomcat bin directory and start Tomcat:

cd /opt/tomcat/bin ./startup.sh

7. Access Tomcat Web Interface:

Open a web browser and access the Tomcat web interface using your server’s IP address and port 8080:

http://your_server_ip:8080

You should see the Tomcat default page.

8. Configure Manager App (Optional):

If you want to manage applications through the Tomcat Manager web application, you’ll need to configure access.

Edit the conf/tomcat-users.xml file:

nano /opt/tomcat/conf/tomcat-users.xml

Add the following lines inside the <tomcat-users> element:

<role rolename="manager-gui"/> <user username="admin" password="your_password" roles="manager-gui"/>

Replace "your_password" with a strong password.

9. Restart Tomcat:

Restart Tomcat to apply the changes:

cd /opt/tomcat/bin ./shutdown.sh ./startup.sh

10. Access Tomcat Manager:

Now, you can access the Tomcat Manager web application using:

http://your_server_ip:8080/manager/html

Log in with the username “admin” and the password you specified.

Apache Tomcat is now installed and running on CentOS 7. You can deploy your Java applications or explore the various features provided by Tomcat.

You May Also Like
Proxmox commands cheat sheet terminal output
Read More

Proxmox Commands – cheat sheet

Managing Proxmox Virtual Environment (PVE) through the command line can significantly speed up administration tasks, especially when working…
secure ssh configuration changing default ssh port for linux and windows servers
Read More

How to Change the SSH Port

Why Change the Default SSH Port? Changing the default SSH port is a common security practice that helps…