How To Install GlassFish on CentOS 8

Install GlassFish on CentOS 8

In this tutorial, we will show you how to install GlassFish on CentOS 8. For those of you who didn’t know, GlassFish is a popular app server that can run java based web applications for you. GlassFish 5 release supports the latest Java Platform: Enterprise Edition 7. It supports Enterprise JavaBeans, JPA, JavaServer Faces, JMS, RMI, JavaServer Pages, servlets, etc.

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 and assumes you are running in the root account, if not you may need to add ‘sudo‘ to the commands to get root privileges. I will show you through the step by step installation GlassFish on a CentOS 8.

Install GlassFish on CentOS 8

Step 1. First, let’s start by ensuring your system is up-to-date.

sudo dnf clean all
sudo dnf update

Step 2. Installing OpenJDK.

Currently, there are two LTS versions of OpenJDK – OpenJDK 8 and OpenJDK 11. You can also install the both Java version on any system and use as per your requirements.

  • Installing OpenJDK 11.
sudo dnf install java-11-openjdk-devel
  • Installing OpenJDK 8.
sudo dnf install java-1.8.0-openjdk-devel

Verify Java version:

java -version

Step 3. Installing Glassfish on CentOS 8.

First, create a user for Glassfish:

useradd -s /sbin/nologin glassfish

Next, download the latest stable version of GlassFish, At the moment of writing this article it is version 5:

unzip -d /opt/

Assign the ownership of /opt/glassfish5 the directory to glassfish user:

chown -R glassfish:glassfish /opt/glassfish5/

Step 4. Create systemd service.

Now we create systemd service (glassfish.service) for Glassfish server:

nano /usr/lib/systemd/system/glassfish.service

Add the following code lines:

Description = GlassFish Server v5.0
After =

User = glassfish
ExecStart = /usr/bin/java -jar /opt/glassfish5/glassfish/lib/client/appserver-cli.jar start-domain
ExecStop = /usr/bin/java -jar /opt/glassfish5/glassfish/lib/client/appserver-cli.jar stop-domain
ExecReload = /usr/bin/java -jar /opt/glassfish5/glassfish/lib/client/appserver-cli.jar restart-domain
Type = forking

WantedBy =

Save changes and exit the file and start the glassfish server also set it to start automatically on boot:

sudo systemctl start glassfish.service
sudo systemctl enable glassfish.service

Step 5. Configure Firewall.

Open HTTP port in the firewall:

sudo firewall-cmd --add-port={4848,8080,8181}/tcp --permanent 
sudo firewall-cmd --reload

Step 6. Accessing GlassFish Web Interface.

GlassFish will be available on HTTP port 8080 by default also port 4848 by the administration. Open your favorite browser and navigate to or http://server-ip-address:4848 and complete the required steps to finish the installation.

Congratulations! You have successfully installed GlassFish. Thanks for using this tutorial for installing the GlassFish 5 in the CentOS 8 system. For additional help or useful information, we recommend you to check the official GlassFish website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!