How to Install Eclipse Jetty Web Server on AnonVM
Eclipse Jetty is a high-performance web server and servlet container. It is lightweight, supports HTTP/2, and is used for serving Java-based applications, providing easy integration with frameworks like Spring and Hibernate. This tutorial will walk you through the process of installing Jetty Web Server on your AnonVM VPS or dedicated server.
Prerequisites
Before starting the installation, ensure the following:
- AnonVM VPS or Dedicated Server with root or sudo privileges.
- Operating System: This tutorial works on Ubuntu/Debian or CentOS.
- Java: Jetty requires Java to run. Make sure you have Java installed on your system.
Step 1: Update Your System
It’s always a good idea to update your system before installing any software to ensure everything is up-to-date.
For Ubuntu/Debian-based systems:
For CentOS-based systems:
Step 2: Install Java
Jetty requires Java 8 or newer. You can install the default Java package available for your distribution.
For Ubuntu/Debian-based systems:
For CentOS-based systems:
You can verify the Java installation by running:
Step 3: Install Eclipse Jetty Web Server
Now, we’ll install Jetty. You can install Jetty by either downloading the distribution or by using package managers if available.
Option 1: Install Jetty Using Package Manager (Ubuntu/Debian-based systems)
-
Install Jetty:
-
Start Jetty: After installation, Jetty should start automatically. To verify that Jetty is running:
If Jetty is not running, start it manually:
-
Enable Jetty to start at boot:
Option 2: Install Jetty from Binary Distribution (Manual Installation)
For more control over your installation, you can manually download and install the Jetty distribution.
-
Download Jetty: Visit the official Eclipse Jetty Downloads page or use the following command to download the latest Jetty release. For example:
-
Extract the Jetty tar file:
-
Move the extracted files to a desired location:
-
Create a Jetty systemd service (optional): If you want to manage Jetty as a systemd service, create a new file
/etc/systemd/system/jetty.service
with the following content: -
Start Jetty: After creating the service file, you can start Jetty:
-
Enable Jetty to start at boot:
-
Verify Jetty is running: To check if Jetty is running properly, you can use the following command:
Step 4: Accessing Jetty Web Server
Once Jetty is installed and running, you can access the default Jetty page by navigating to the IP address or domain of your server in a web browser:
You should see the Jetty welcome page, confirming that the web server is up and running.
Step 5: Configure Jetty for Your Application
Jetty is often used to serve Java-based applications, such as those built with Spring or other Java frameworks. You can configure Jetty to deploy web applications by adding them to the webapps/
directory.
-
Deploy a Web Application:
- Create a
.war
(Web Application Archive) file for your Java application. - Move the
.war
file to thewebapps/
directory of your Jetty installation:
- Create a
-
Restart Jetty: After deploying your application, restart Jetty to load the new application:
-
Access Your Application: You can now access your deployed application in a web browser:
Step 6: Secure Jetty with SSL/TLS
To secure your Jetty server with HTTPS, you can use Let’s Encrypt for a free SSL certificate.
-
Install Certbot: Certbot is a tool that automates the process of obtaining and renewing SSL certificates from Let’s Encrypt.
For Ubuntu/Debian-based systems:
For CentOS-based systems:
-
Obtain an SSL Certificate: To obtain a certificate for your domain, use Certbot’s webroot plugin. Replace
yourdomain.com
with your actual domain name: -
Configure Jetty for SSL: Jetty can be configured to use SSL by modifying its
start.ini
or creating a newjetty-ssl.xml
file to point to your SSL certificates. You'll need to configure the keystore for SSL and enable HTTPS. -
Restart Jetty: After configuring SSL, restart Jetty:
-
Verify SSL Configuration: You should now be able to access your Jetty server over HTTPS:
Step 7: Monitor and Manage Jetty Web Server
-
Check Jetty status:
-
View Jetty logs: Jetty logs can typically be found in
/var/log/jetty/
or/opt/jetty/logs/
depending on your installation method. You can view the logs using: -
Stop, start, or restart Jetty:
- Stop Jetty:
- Start Jetty:
- Restart Jetty:
Conclusion
You have successfully installed and configured Eclipse Jetty Web Server on your AnonVM VPS or dedicated server. By following this tutorial, you now have a scalable, fast web server running Java-based applications, with SSL support to secure your traffic. Jetty's lightweight nature makes it a great choice for handling modern web applications.