How To Install Jetty on Debian 9 Stretch

Install Jetty on Debian 9 Stretch

In this tutorial, we will show you how to install Jetty on Debian 9 Stretch. For those of you who didn’t know, Jetty is now often used for machine-to-machine communications, usually within larger software frameworks. Jetty is developed under an open-source license, part of the Eclipse foundation. Jetty is also the server in open source projects such as Lift, Eucalyptus, Red5, Hadoop, and I2P. Jetty supports the latest Java Servlet API (with JSP support) as well as protocols SPDY and WebSocket.

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo‘ to the commands to get root privileges. I will show you through the step-by-step installation Jetty web server on a Debian 9 (Stretch) server.

Install Jetty on Debian 9 Stretch

Step 1. Before we install any software, it’s important to make sure your system is up to date by running the following apt-get commands in the terminal:

sudo apt update 
sudo apt upgrade

Step 2. Installing Java via PPA on Debian 9.

Add the Webupd8 Team PPA repository, run the following commands on your server:

echo "deb http://ppa.launchpad.net/webupd8team/java/ubuntu xenial main" | tee /etc/apt/sources.list.d/webupd8team-java.list
echo "deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu xenial main" | tee -a /etc/apt/sources.list.d/webupd8team-java.list
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys EEA14886
apt-get update

Then, install JDK8 with the following command:

apt-get install oracle-java8-installer

Step 3. Installing Jetty on Debian 9.

First, install some modules that are required by Jetty with the following command:

apt-get install authbind glassfish-jmac-api libapache-pom-java libasm-java libatinject-jsr330-api-java libcommons-dbcp-java libcommons-logging-java
libcommons-parent-java libcommons-pool-java libecj-java libjetty9-extra-java libjetty9-java libmail-java libservlet3.1-java libspring-beans-java
libspring-core-java libtaglibs-standard-impl-java libtaglibs-standard-spec-java libtomcat8-java

Next, download the latest version of jetty:

wget -c http://repo1.maven.org/maven2/org/eclipse/jetty/jetty-distribution/9.3.12.v20160915/jetty-distribution-9.3.12.v20160915.zip
unzip jetty-distribution-9.3.12.v20160915.zip
mv jetty-distribution-9.3.12.v20160915 jetty
mv jetty /opt

We will create a user and group named jetty. First, create the group first:

sudo addgroup --quiet --system jetty
adduser --quiet --system --ingroup jetty --no-create-home --disabled-password jetty
usermod -c "Jetty" -d /opt/jetty -g jetty jetty

Change ownership of /opt/jetty directory to user jetty and group jetty:

chown -R jetty:jetty /opt/jetty

Next, Symlink the jetty.sh script to the /etc/init.d/ directory to create a startup script file:

ln -s /opt/jetty/bin/jetty.sh /etc/init.d/jetty

Then, add the following information in /etc/default/jetty, replace port and listening address with your value:

nano /etc/default/jetty
JETTY_HOME=/opt/jetty
JETTY_USER=jetty
JETTY_PORT=8080
JETTY_HOST=y0ur_server_IP
JETTY_LOGS=/opt/jetty/logs/

Step 4. Access the Jetty Installation.

The Jetty web server runs on port 8080. To access your Jetty installation, you will need to type the following URL in your web browser: http://your-ip-address:8080/

Congratulations! You have successfully installed Jetty. Thanks for using this tutorial for installing the latest version of the Jetty web server on the Debian 9 server. For additional help or useful information, we recommend you to check the official Jetty website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!