Install GlassFish on CentOS 8 - A step by Step guide ?

GlassFish is an open-source and Java-supported application server through which users can run Java-based applications. It supports the latest Java platforms such as Enterprise JavaBeans, JavaServer Faces, JPA, JavaServer Pages, JMS, RMI and servlets, etc. Glassfish allows developers to build enterprise applications that are scalable and portable and can integrate with legacy technologies. Users can also install optional components for providing additional services.

Here at LinuxAPT, as part of our Server Management Services, we regularly help our Customers to perform related Linux application server queries.

In this context, we shall look into the installation procedure of the GlassFish application server on the CentOS 8 system


How to Install GlassFish Application Server on CentOS 8 ?

Before performing this installation procedure, ensure that Root privileges are required to assign administrative roles and systemd services configurations.

Then follow the step by step guide to install the GlassFish server.


1. Install Java OpenJDK 

At that time, different Java versions are available for installation. However, for convenience install only the most commonly used LTS OpenJDK Java version OpenJDK 11 and 8. Most of the application supports OpenJDK 11 and some support OpenJDK 8. Therefore, install both Java versions one by one on CentOS 8 system. First, install the OpenJDK 11 by using the below-mentioned command:

$ sudo dnf install java-11-openjdk-devel

Once the OpenJDK 11 is installed on your system, type the following command to install OpenJDK 8 on CentOS 8:

$ sudo dnf install java-1.8.0-openjdk-devel

Then, Verify the installation of Java by running the below-given command:

$ java -version

Now, to switch between two Java alternatives use the following command:

$ update-alternatives --config java

With the above command, select the number that Java version you want to use on your system as the default version.


2. Install GlassFish

First, add a user for Glassfish by running the below command using root privileges:

$ useradd -s /sbin/nologin glassfish


3. Download GlassFish Stable version

Download the GlassFish most stable version according to the requirement on your system using the 'wget' command as follows:

$ wget http://download.oracle.com/glassfish/5.0/release/glassfish-5.0.zip

This command will download the available latest version from the oracle website. The zip file will download on your system.


4. Unzip the GlassFish release

Unzip the downloaded file by using the unzip command. Type the below-given terminal command to unzip the glassfish zipped file:

$ unzip -d /opt/ glassfish-5.0.zip

Now, assign privileges to the GlassFish user of the '/opt/ glassfish5/' directory:

$ chown -R glassfish:glassfish /opt/glassfish5/


5. Create GlassFish systemd service

Now, create the (glassfish.service) systemd service for running GlassFish server on CentOS 8. Create a file using text editor as follows:

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

Here, Paste the following lines of code in this systemd service file:

[Unit]
Description = GlassFish Server v5.0
After = syslog.target network.target
[Service]
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
[Install]
WantedBy = multi-user.target

Now, exit from the current displaying window after saving all changes in this file.


7. Enable and start GlassFish server

Start the GlassFish server and enable it on CentOS 8 system by running the below-mentioned commands:

$ sudo systemctl start glassfish.service
$ sudo systemctl enable glassfish.service
$ sudo systemctl status glassfish.service


7. Firewall Configuration

Configure the firewall setting. Open the HTTP ports (4848, 8080, and 8181) in the firewall for running the Glassfish server:

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

The success status should display on the terminal for enabling the firewall settings.


8. Launch GlassFish server web interface

GlassFish can listen on HTTP as default port 8080 and port 4848 by the administration. So, open the web browser Mozila Firefox and enter one of the following URLs in the address bar:

http://domain.com:8080

Or

http://IP-Address-Server:4848

The glassfish web interface will launch on the system after completing the required login steps automatically.


[Need assistance in Installing Open Source Software on Debian Linux system ? We can help you. ]

This article covers how to install the GlassFish application server on CentOS 8. In fact, GlassFish allows developers to create enterprise applications that are portable and scalable, and that integrate with legacy technologies. Also, you will see the best way to define systemd services for running Glassfish server and firewall configurations. 

To Start and enable glassfish services, simply run the below command:

$ systemctl start glassfish.service
$ systemctl enable glassfish.service
To access Glassfish Server on CentOS / RHEL 8, simply browse the below URL to access Glassfish Admin Console, ignore the certificate warning or install it:
https://SERVER-IP-OR-DOMAIN-NAME:4848/

Related Posts