About Apache Tomcat
Apache tomcat is a Java based application server released by the Apache Software Foundation. It is a web server and a servlet container for Java web applications.
Setup
Tomcat installation required dependency as Java and this tutorial will include a step on how to install that platform.
Step 1 : Install Java
Step 2 : Install Tomcat7
Note : You do need to have a user with sudo privileges for this tutorial.
Step 1 : Install Java
We installed the entire Apache Tomcat server on our virtual server in the previous step. Before we can use it, however, we do need to have Java installed on the VPS as well. If you currently do not have java, you can download it quite easily with apt-get.
sudo apt-get install default-jdk
Once you have Tomcat and Java installed on the virtual private server, all that remains is to start them.
OR
For Installing Oracle JDK
sudo apt-add-repository ppa:webupd8team/java sudo apt-get update sudo apt-get install oracle-java8
-installer
Also ensure your JAVA_HOME
variable has been set to:
/usr/lib/jvm/java-8-oracle
Step 2 : Install Tomcat
The most recent version of Tomcat is 7, and it can be easily downloaded through apt-get or from the Apache Tomcat site.
You can download it through apt-get by typing:
sudo apt-get install tomcat7
To download tomcat from their site, copy the link for the tar.gz package under the “Core” section and begin the download. You will get a link that originates from one of Apache’s many mirrors, making the command look mostly like this (although coming from a different site).
wget http://apache.mivzakim.net/tomcat/tomcat-7/v7.0.57/bin/apache-tomcat-7.0.57.tar.gz
After the download completes, untar the file.
tar xvzf apache-tomcat-7.0.57.tar.gz
Finish up the Tomcat installation on the VPS by moving the files to a convenient directory.
sudo mv apache-tomcat-7.0.57 ~/path/to/tomcat
Step 3 : Configure .bashrc
In order to start Tomcat, we need to add it as an environment variable in the /.bashrc file.
sudo nano ~/.bashrc
You can add this information to the end of the file:
export JAVA_HOME=/usr/lib/jvm/default-java
For Oracle JDK:
export JAVA_HOME=/usr/lib/jvm/default-java
Path Setup For Tomcat7
export CATALINA_HOME=~/path/to/tomcat
Save and exit out of .bashrc. You can make the changes effective by restarting the bashrc file.
. ~/.bashrc
Once you have Tomcat and Java installed on the virtual private server, all that remains is to start them.
For Starting tomcat7:
sudo service tomcat7 start
For Stoping tomcat7:
sudo service tomcat7 stop
For Restart tomcat7:
sudo service tomcat7 start