Install JAVA 1.8 and Tomcat Server 9 in CentOS 7

May 05, 2018 | 74 views | Comments

Along with JAVA and inside CentOS, power you web application with Apache Tomcat, one of the most popular open source software implementation of the Java Servlet, JavaServer Pages, Java Expression Language and Java WebSocket technologies. Below is a step-by-step tutorial on installing JAVA and Tomcat in CentOS.

 

Step 1. Install JAVA.

$ sudo yum install java-1.8.0-openjdk

Check JAVA installation.

$ java -version

 

Step 2. Create a folder for "tomcat".

Create a new folder "tomcat" inside the "/opt" directory.

$ cd /opt

$ sudo mkdir tomcat

 

Step 3. Create a new group for "tomcat".

$ sudo groupadd tomcat

 

Step 4. Create a new user for "tomcat".

  • Disable shell access.
  • Add to "tomcat" group.
  • Set the home folder to the created "tomcat" folder.

$ sudo useradd -s /bin/false -g tomcat -d /opt/tomcat tomcat

 

Step 5. Download apache tomcat server file inside the "tomcat" folder.

$ cd /opt/tomcat

$ sudo wget http://www-us.apache.org/dist/tomcat/tomcat-9/v9.0.7/bin/apache-tomcat-9.0.7.tar.gz

 

Step 6. Untar the downloaded apache tomcat server file.

$ sudo tar -xvf apache-tomcat-9.0.7.tar.gz

 

Step 7. Change group and ownership of the utarred folder "apache-tomcat-9.0.7" to both user tomcat, and group tomcat.

$ sudo chown tomcat:tomcat -R apache-tomcat-9.0.7

 

That's all!

JAVA (openjdk 1.8.0_161) and Tomcat (9.0.7) has been installed on CentOS 7.

 

Note: "/opt/tomcat/apache-tomcat-9.0.7" is the HOME/BASE of CATALINA.

 

Start tomcat. Requires a root access.

Go to the bin folder and execute the startup.sh file.

$ sudo su

$ cd /opt/tomcat/apache-tomcat-9.0.7/bin

$ ./startup.sh

Check if the tomcat start was successful by opening a browser and go to http://localhost:8080/

 

Stop tomcat. Requires a root access.

Go to the bin folder and execute the shutdown.sh file.

$ sudo su

$ cd /opt/tomcat/apache-tomcat-9.0.7/bin

$ ./shutdown.sh

Check if the tomcat shutdown was successful by opening a browser and go to http://localhost:8080/

 

What's Next? Run Tomcat Server as a Service.

Read the tutorial Run Tomcat Server as a Service in CentOS 7 for the complete step-by-step guide.

 

Related Tutorials


Must Read