Table of Contents
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 update2. 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-devel3. 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.gzExtract the downloaded archive:
sudo tar -xf apache-tomcat-<Tomcat_Version>.tar.gz -C /opt4. Create a Symbolic Link:
Create a symbolic link to make it easier to manage the Tomcat installation:
sudo ln -s /opt/apache-tomcat-<Tomcat_Version> /opt/tomcat5. Configure Environment Variables:
Edit the ~/.bashrc file to set environment variables:
nano ~/.bashrcAdd 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 ~/.bashrc6. Start Apache Tomcat:
Navigate to the Tomcat bin directory and start Tomcat:
cd /opt/tomcat/bin ./startup.sh7. 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:8080You 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.xmlAdd 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.sh10. Access Tomcat Manager:
Now, you can access the Tomcat Manager web application using:
http://your_server_ip:8080/manager/htmlLog 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.