Tag Archives: apache 9 in linux

How to install Apache Tomcat 9 in Linux

Learn how to install Apache 9 in Linux like RedHat, CentOs, Suse, OEL etc.

Apache Tomcat 9 installation

This is a quick post to a list of steps for Apache Tomcat 9 installation on Linux. Let’s start with download the software. Get your Apache Tomcat 9 from the official download page.

Apache being a webserver is part of LAMP stack. Red more about LAMP here.

First download core binary file from the official download page. Use tools like wget to download a file right on your server itself.

root@kerneltalks # wget http://mirrors.estointernet.in/apache/tomcat/tomcat-9/v9.0.14/bin/apache-tomcat-9.0.14.tar.gz

Now extract the tarball. You will have apache-tomcat-9.0.14 directory after unzipping.

root@kerneltalks # tar -xvf apache-tomcat-9.0.14.tar.gz

Now move the directory or its content to your required directory where you want your Apache Tomcat binaries should stay & you are done. For demonstration, I moved them in /opt

root@kerneltalks #  mv apache-tomcat-9.0.14 /opt

You have startup.sh and shutdown.sh scripts in the bin directory. Test them and you are all set. If you do not have java installed on your server, you will see below error while you try to start Apache.

root@kerneltalks #  cd /opt/apache-tomcat-9.0.14/bin
root@kerneltalks # sh startup.sh
Neither the JAVA_HOME nor the JRE_HOME environment variable is defined
At least one of these environment variable is needed to run this program

Install java package using your package manager according to Linux you use. The package installation will set the above variables automatically. Then you can try starting Apache again.

root@kerneltalks # ]# sh startup.sh
Using CATALINA_BASE:   /opt/apache-tomcat-9.0.14
Using CATALINA_HOME:   /opt/apache-tomcat-9.0.14
Using CATALINA_TMPDIR: /opt/apache-tomcat-9.0.14/temp
Using JRE_HOME:        /
Using CLASSPATH:       /opt/apache-tomcat-9.0.14/bin/bootstrap.jar:/opt/apache-tomcat-9.0.14/bin/tomcat-juli.jar
Tomcat started.

And here you go. Your Apache instance is started with the default configuration. It listens on port 8080 by default. You can open your server IP in a browser and make sure you get default Apache page like below –

Apache welcome page

If not then check if port 8080 is listening or not. If you have a server in AWS, then make sure you open port in the related security group of your instance.

root@kerneltalks # netstat -an |grep 8080
tcp6       0      0 :::8080                 :::*                    LISTEN

Try restarting instance and you should be pass through!