The Jetty is a free open source hundred percent jave based web server which provides http server servlet and container for serving java base static and dynamic contents. Today many java base servlets and containers are available such as Apache Tomcat, Eclipse Jetty, Glassfish but jetty is widely used for system to system communication. Apache Maven, Google App Engine, Apache Geronimo and Eclipse etc. generally used by jetty. Apache Hadoop also use jetty web server in framwork.
Jetty provide high level performance, stability, reliablity, Collaboration for enterprise application, as performance is most crucial for any application and business to make them successful.
Jetty 9 is current release version of jetty web server.
In this acrticle you will learn to setup jetty web server on linux districution.
Jetty generally requires java so first of all we need to install java.
For Centos.
For Ubuntu
If you want to install source code instead of package manager then follow the below steps.
[root@linuxpcfix ~]#wget http://download.oracle.com/otn-pub/java/jdk/8u20-b26/jdk-8uxyzy-linux-x64.tar.gz
[root@linuxpcfix ~]# tar -xvf jdk-8uxyzy -linux-x64.tar.gz
[root@linuxpcfix ~]# ln -s jdk1.8.0_xyzy/ java
[root@linuxpcfix ~]# export JAVA_HOME=”/usr/local/java”
[root@linuxpcfix ~]# cd /java
[root@linuxpcfix ~]#bin/java -version
bin/java -version
java version “1.8.0_20?
Java(TM) SE Runtime Environment (build 1.8.0_20-b26)
Java HotSpot(TM) 64-Bit Server VM (build 25.20-b23, mixed mode)
Note :: Please repalce “xyzy” with actual java version
Now download the current release jetty from source code.
[root@linuxpcfix ~]# wget http://eclipse.org/downloads/download.php?file=/jetty/stable-9/dist/jetty-distribution-9.2.7.v20150116.tar.gz
[root@linuxpcfix ~]# tar -xvf jetty-distribution-9.2.xy.v20150116.tar.gz
Note :: replace xy with actual jetty version here we are using 9.2.7 jetty version
after the create new user with name jetty as given below.
[root@linuxpcfix ~]chown -R jetty:jetty /usr/local/jetty
To start and stop the jetty server create startup script as below.
[root@linuxpcfix ~]#/usr/local/jetty/bin/jetty.sh /etc/init.d/jetty
[root@linuxpcfix ~]#chkconfig jetty on
Then append the following lines in /etc/default/jetty file
JETTY_HOME=/usr/local/jetty
JETTY_USER=jetty
JETTY_PORT=7070
JETTY_HOST=server-ip-address
JETTY_LOGS=/usr/local/jetty/logs/
Finally start jetty server by using following command.
[root@linuxpcfix ~]# service jetty check
[root@linuxpcfix ~]# netstat -plan |grep:7070
Open you favorite web browser and open the jetty website as http://your-ip-address:7070