Apache Tomcat, often referred to as Tomcat, is an open-source application server developed by the Apache Software Foundation. It implements several Java EE specifications and executes Java servlets rendering Web pages that include Java Server Page coding in the process.
In this article we will guide you through the steps on installing the latest Tomcat 8 server on a Debian 8 VPS.
This guide should work on other Debian systems as well but was tested and written for a Debian 8 (Jessie) OS.
Login to your server via SSH
ssh [email protected]_ip
Reassure that you have the proper version of Debian installed on our server :
# lsb_release -a Distributor ID: Debian Description: Debian GNU/Linux 8.2 (jessie) Release: 8.2 Codename: jessie
We will be using our SSD 1 Linux VPS hosting plan for this tutorial.
UPDATE THE SYSTEM
Make sure your server is fully up to date and install wget and unzip:
# apt-get update && apt-get upgrade # apt-get install unzip wget
INSTALL JRE 8
Add the webupd8team Java PPA repository in your Debian system. After that you will be able to install the latest JRE (Java SE Runtime Environment) which is needed for Tomcat to run. Issue the following commands:
# echo "deb http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main" | tee /etc/apt/sources.list.d/webupd8team-java.list # echo "deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main" | tee -a /etc/apt/sources.list.d/webupd8team-java.list # apt-key adv --keyserver keyserver.ubuntu.com --recv-keys EEA14886
Update the package index and install Java 8:
# apt-get update # apt-get install oracle-java8-installer
Check if Java has been properly installed:
# java -version
The following output should be received:
java version "1.8.0_66" Java(TM) SE Runtime Environment (build 1.8.0_66-b17) Java HotSpot(TM) 64-Bit Server VM (build 25.66-b17, mixed mode)
We recommend you to create a separate system user which will run the Tomcat server. Therefore, issue the following command:
# useradd -r tomcat --shell /bin/false
Now download the latest Tomcat version from their official website. Use the below command to download Tomcat 8.0.41 into the ‘opt’ directory.
# wget https://archive.apache.org/dist/tomcat/tomcat-8/v8.0.41/src/apache-tomcat-8.0.41-src.tar.gz -P /opt
Enter the ‘opt’ directory:
# cd /opt
Unpack the archive:
# tar -zxf /opt/apache-tomcat-8.0.41.tar.gz
Next, create a symbolic link of the Tomcat directory to /opt/tomcat-latest and set the appropriate ownership:
# ln -s /opt/apache-tomcat-8.0.41 /opt/tomcat-latest # chown -hR tomcat: /opt/tomcat-latest /opt/apache-tomcat-*
Let’s create a systemd init file so you can start/restart/stop Tomcat.
# nano /etc/systemd/system/tomcat.service
Once opened, paste the following:
[Unit] Description=Tomcat8 After=network.target [Service] Type=forking User=tomcat Group=tomcat Environment=CATALINA_PID=/opt/tomcat-latest/tomcat8.pid Environment=TOMCAT_JAVA_HOME=/usr/bin/java Environment=CATALINA_HOME=/opt/tomcat-latest Environment=CATALINA_BASE=/opt/tomcat-latest Environment=CATALINA_OPTS= Environment="JAVA_OPTS=-Dfile.encoding=UTF-8 -Dnet.sf.ehcache.skipUpdateCheck=true -XX:+UseConcMarkSweepGC -XX:+CMSClassUnloadingEnabled -XX:+UseParNewGC -XX:MaxPermSize=128m -Xms512m -Xmx512m" ExecStart=/opt/tomcat-latest/bin/startup.sh ExecStop=/bin/kill -15 $MAINPID [Install] WantedBy=multi-user.target
Enter the underneath commands to start Tomcat and enable it to start on boot:
# systemctl daemon-reload # systemctl restart tomcat # systemctl enable tomcat
Congratulations, you have successfully installed Tomcat 8 on your Debian 8 VPS. Now to access Tomcat, open your favorite web browser and navigate to http://your_server_IP:8080
Of course you don’t have to do any of this if you use one of our Linux VPS Hosting services, in which case you can simply ask our expert Linux admins to install Tomcat 8 for you. They are available 24×7 and will take care of your request immediately.
PS. If you liked this post please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.