Installation and configuration of Jetty under Linux

Keywords: Jetty Java JDK RPM

Jetty introduction

Jetty is an open source servlet container that provides a runtime environment for Java based web content, such as JSP S and servlets. Jetty is written in the Java language, and its API is published as a set of JAR packages. Developers can instantiate the jetty container into an object, which can quickly provide network and web connection for some stand-alone Java applications.

Download Jetty 9.
Official website: http://www.eclipse.org/jetty/ .

1. Install and configure java (note the java version corresponding to the downloaded jetty)

#Check whether the system comes with java, if any, uninstall it first.
java -version  #Check version
rpm -qa | grep java  #View installed jdk packages
rpm -e  java-1.7.0-openjdk -–nodeps #Uninstall jdk
rpm -e  java-1.6.0-openjdk -–nodeps #Uninstall jdk

#Unzip java installation package
# tar zxvf jdk-7u79-linux-x64
# chmod +x -R /usr/loacl/jdk-7u79-linux  #Permissions

#Configure java environment variables
vim /etc/profile
export JAVA_HOME=/java/jdk1.7.0_79
export CLASSPATH=.:$JAVA_HOME</span>/jre/lib/rt.jar:<span class="hljs-variable">$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$PATH</span>:<span class="hljs-variable">$JAVA_HOME/bin

#Check after recompilation
source /etc/profile
java -version
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19

2. Install and configure jetty

#decompression
tar -zxvf jetty-distribution-9.2.22.v20170606.tar.gz

#Configure jetty environment variables
vim /etc/profile
export JETTY_HOME=/usr/local/jetty-distribution-9.2.22.v20170606.tar.gz
export PATH=$PATH:$JETTY_HOME/bin
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7

3. Start test jetty

#At the beginning of webapps, there was nothing. We copied jetty's demo for test access
cp -r /usr/local/jetty/demo-base/webapps/ROOT /usr/local/jetty/webapps/

#Start jetty
./bin/jetty.sh start 

#Browser access
http://localhost:8080
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8

4. Configure jetty's startup port (as required)

#Open the start.ini configuration file in the jetty installation directory
vim start.ini

#Find jetty? Port and modify its value (different jetty version keywords are different)
jetty.port=9999

#Access by configured port after restart
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7

5. Introduction to Jetty's catalog

license-eplv10-aslv20.html #Jetty license file

README.txt #Entry information

VERSION.txt #release information

bin/ #Run Jetty's secondary shell script

demo-base/ #Demo demo

etc/ #Jetty XML configuration file directory, mainly including the configuration files required by each module

lib/ #All the JAR packages needed to run Jetty

logs/ #log directory

modules/ #Module definition directory, such as server, http, https and other module definition files

notice.html #License information

resources/ #Additional resource information, such as log4j configuration

start.d/ #Contains a series of global ini files, each of which stores various command line parameters

start.ini #Global command line parameter file, the contents of which will be added to the command line parameters, that is, java -jar start.jar [arg...] parameters of the command

start.jar #Jar file to run Jetty

webapps/ #webapps folder
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29

It's very easy to deploy applications in Jetty. Just put the war package or the directory containing content under the webapps directory.

Posted by rix on Mon, 06 Jan 2020 16:57:05 -0800