Want your very own server? Get our 1GB memory, Xeon V4, 25GB SSD VPS for £10.00 / month.
Get a Cloud ServerJetty is developed as an open source application under the Eclipse Foundation project. In this tutorial we'll learn how-to install Jetty 8 on Ubuntu 14.04 from scratch. This tutorial assumes you have clean installation of Ubuntu 14.04.
To make sure that our system is secure, the first thing that we want to do to our base system is to update the system to latest packages. To do this, run the following:
$ sudo apt-get update
$ sudo apt-get upgrade
After updating the base system to latest release, we're ready to install the prerequisite of Jetty 8.
Jetty needs Java to run. We will use Oracle JDK 8 instead of OpenJDK in this tutorial. We will install JDK 8 using Webupd8 team PPA.
Add the webupd8team ppa repository :
$ sudo add-apt-repository ppa:webupd8team/javaPress [ENTER] to continue or ctrl-c to cancel adding it
OK
You need to press enter to continue adding the webupd8team PPA repository. The output above has been truncated to show you only the most important parts.
Let apt-get download and read the metadata of the new repository that we just added:
$ sudo apt-get update
Install JDK 8.
$ sudo apt-get -y install oracle-java8-installer
the -y
option above will make you agree automatically with packages to be installed including dependencies. If you want to check what packages will be installed you can remove the -y
option.
Package configuration. Choose OK
Yes
After installing Java 8, you can check the current java version by running command below :
$ java -version
java version "1.8.0_45"
Java(TM) SE Runtime Environment (build 1.8.0_45-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)
We've confirmed that we have JDK 8 installed.
All the prerequisite already installed. Now we can install Jetty 8 from Repository.
$ sudo apt-get install jetty8
Jetty 8 is installed but it's not ready yet because by default it's disabled. If you try to start the service you will get a warning.
$ sudo service jetty8 start
* Not starting jetty - edit /etc/default/jetty8 and change NO_START to be 0 (or comment it out).
To enable Jetty so that we can start the service, edit /etc/defaults/jetty8
. On line 4 you'll find :
NO_START=1
Change it to :
NO_START=0
Let's start the service
$ sudo service jetty8 start
' * Starting Jetty servlet engine. jetty8 * Jetty servlet engine started, reachable on http://two.testserver.pw:8080/. jetty8 [ OK ]
If you are installing Jetty on computer that you currently use you can open http://localhost:8080. If you are installing Jetty on remote computer you are not able to access Jetty yet, for example when you access http://:8080.
Let's check where Jetty 8 listens :
$ sudo netstat -naptu | grep 8080
tcp6 0 0 127.0.0.1:8080 :::* LISTEN 8409/java
Jetty is already listen on port 8080 but only on 127.0.0.1 or localhost. That's why we cannot access it from remote server. We'll make Jetty listen to all interfaces.
Open file vi /etc/jetty8/jetty.xml
. Find line below (line 39):
Change it to the below :
0.0.0.0
If you want Jetty to listen to a specific IP address, for example 192.168.100.100, you can change it to :
192.168.100.100
Now, let's restart the Jetty 8 service :
$ sudo service jetty8 restart
* Stopping Jetty servlet engine (was reachable on http://two.testserver.pw:8080/). jetty8 * Jetty servlet engine stopped. jetty8 [ OK ]
* Starting Jetty servlet engine. jetty8 * Jetty servlet engine started, reachable on http://two.testserver.pw:8080/. jetty8 [ OK ]
Let's check where Jetty8 listens :
$ sudo netstat -naptu | grep 8080
tcp6 0 0 :::8080 :::* LISTEN 8589/java
Jetty8 is listening on all interfaces and IP address. Now, you can open http://:8080. You will see a welcome page of Jetty:
In this tutorial we learned how-to install Jetty 8 on Ubuntu 14.04. We learned how-to update the server to latest update, install JDK 8 from Oracle then install and configure Jetty 8. Now you can start deploying your Java app to Jetty. Have Fun!
Want your very own server? Get our 1GB memory, Xeon V4, 25GB SSD VPS for £10.00 / month.
Get a Cloud Server
Related Posts
Comments