In this tutorial, we will show you how to install Jetty Web Server on CentOS 7. For those of you who didn’t know, Jetty is a pure Java-based HTTP (Web) server and Java Servlet container. 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 Eclipse foundation, it is used in multiple active products such as Apache ActiveMQ, Alfresco, Apache Geronimo, Apache Maven, and Apache Spark, and also in open source projects such as Hadoop, Eucalyptus, Twitter’s Streaming API and Zimbra.
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. I will show you the step-by-step installation of Jetty on CentOS 7.
Prerequisites
- A server running one of the following operating systems: CentOS 7.
- It’s recommended that you use a fresh OS install to prevent any potential issues.
- SSH access to the server (or just open Terminal if you’re on a desktop).
- A
non-root sudo user
or access to theroot user
. We recommend acting as anon-root sudo user
, however, as you can harm your system if you’re not careful when acting as the root.
Install Jetty Web Server on CentOS 7
Step 1. First of all, we have to install Java JDK.
yum install java-1.7.0-openjdk wget
Step 2. Installing Jetty on CentOS 7.
Download the latest version of the jetty.
wget http://mirror.neu.edu.cn/eclipse/jetty/stable-9/dist/jetty-distribution-9.2.11.v20150529.tar.gz tar zxvf jetty-distribution-9.2.11.v20150529.tar.gz -C /opt/
Rename the file name to jetty:
mv /opt/jetty-distribution-9.2.11.v20150529/ /opt/jetty
Step 3. Create a user called jetty to run a jetty web server on system start-up.
adduser -r -m jetty chown -R jetty:jetty /opt/jetty/ cd /etc/init.d ln -s /opt/jetty/bin/jetty.sh jetty chkconfig --add jetty chkconfig --level 345 jetty on
Step 4. Configure Jetty.
Add the following information in /etc/default/jetty
, replace the port and listening address with your value:
#nano /etc/default/jetty JETTY_HOME=/opt/jetty JETTY_USER=jetty JETTY_PORT=8080 JETTY_HOST=192.168.1.16 JETTY_LOGS=/opt/jetty/logs/
Step 5. Start Jetty webserver
You should now be able to start Jetty freely with the following command:
service jetty start
Now you can access the jetty webserver at http://your-ip-address:8080
Congratulations! You have successfully installed Jetty. Thanks for using this tutorial for installing Jetty webserver on centos 7 systems. For additional help or useful information, we recommend you to check the official Jetty website.