Easy Steps To Install GlassFish on Rocky Linux 9 – OrcaCore
This guide, brought to you by Orcacore, will walk you through the process of How To Install GlassFish on Rocky Linux 9. GlassFish is a robust, open-source, and freely accessible Java EE (formerly J2EE) application server. It provides a comprehensive environment for developing and deploying Java applications compliant with Java EE specifications.
Like other Java EE-compliant application servers, GlassFish provides the necessary libraries to develop and deploy Java applications compliant with Java EE specifications. Java EE technologies encompass a wide range of features including Servlets, JavaServer Pages (JSPs), JavaServer Faces (JSF), Enterprise JavaBeans (EJBs), and the Java Messaging Service (JMS).
Before we begin, ensure you have the following prerequisites in place: a server running Rocky Linux 9, a non-root user account with sudo privileges, and a basic firewall configured. You can follow the Initial Server Setup with Rocky Linux 9 guide on Orcacore for detailed instructions.
1. Install Java For GlassFish Setup
To successfully Install GlassFish on Rocky Linux 9, Java needs to be installed on your server. Let’s begin by updating your local package index:
sudo dnf update
Next, enable the EPEL (Extra Packages for Enterprise Linux) repository, which provides additional packages not found in the default repositories:
sudo dnf install epel-release -y
Now, install Java 11 OpenJDK development package:
sudo dnf install java-11-openjdk-devel -y
Once the installation is complete, verify your Java installation by checking its version:
java -version
The output should resemble the following:
**Output**
openjdk version "11.0.16.1" 2022-08-12 LTS
OpenJDK Runtime Environment (Red_Hat-11.0.16.1.1-1.el9_0) (build 11.0.16.1+1-LTS)
OpenJDK 64-Bit Server VM (Red_Hat-11.0.16.1.1-1.el9_0) (build 11.0.16.1+1-LTS, mixed mode, sharing)
2. Install GlassFish on Rocky Linux 9
Now that Java is set up, we can proceed to install GlassFish itself. First, create a dedicated user account for GlassFish:
sudo useradd -s /sbin/nologin glassfish
Download GlassFish
Visit the GlassFish Downloads Page to check the latest version. Then, download the GlassFish installer using wget
:
sudo wget https://download.eclipse.org/ee4j/glassfish/glassfish-6.2.5.zip
Remember to replace the version number with the one you obtained from the GlassFish downloads page.
Extract the downloaded file to the /opt/
directory:
sudo unzip -d /opt/ glassfish-6.2.5.zip
Set the correct ownership permissions for the GlassFish user:
sudo chown -R glassfish:glassfish /opt/glassfish6/
Create Systemd Unit File For GlassFish
To manage GlassFish as a system service, create a systemd unit file. Use your preferred text editor (like vi
) to create and open the file:
sudo vi /usr/lib/systemd/system/glassfish.service
Add the following content to the file:
[Unit]
Description = GlassFish Server v6.2.5
After = syslog.target network.target
[Service]
User = glassfish
ExecStart = /usr/bin/java -jar /opt/glassfish6/glassfish/lib/client/appserver-cli.jar start-domain
ExecStop = /usr/bin/java -jar /opt/glassfish6/glassfish/lib/client/appserver-cli.jar stop-domain
ExecReload = /usr/bin/java -jar /opt/glassfish6/glassfish/lib/client/appserver-cli.jar restart-domain
Type = forking
[Install]
WantedBy = multi-user.target
Save and close the file. Then, reload the systemd
daemon to apply the changes:
sudo systemctl daemon-reload
Start and Enable GlassFish Service
Start the GlassFish service:
sudo systemctl start glassfish
Enable GlassFish to start automatically at boot:
sudo systemctl enable glassfish
Verify that the GlassFish service is active and running:
sudo systemctl status glassfish
The output should indicate that the service is active and running:
**Output**
● glassfish.service - GlassFish Server v6.2.5
Loaded: loaded (/usr/lib/systemd/system/glassfish.service; enabled; vendor preset: disabled)
Active: **active** (**running**) since Sat 2023-01-06 06:48:24 EDT; 16s ago
Main PID: 16744 (java)
Tasks: 98 (limit: 23609)
Memory: 383.2M
CPU: 16.098s
CGroup: /system.slice/glassfish.service
...
3. Configure Firewall For GlassFish
Assuming you have firewalld
enabled, allow the necessary GlassFish ports through the firewall:
sudo firewall-cmd --add-port={4848,8080,8181}/tcp --permanent
Reload the firewall to apply the new rules:
sudo firewall-cmd --reload
4. Configure GlassFish on Rocky Linux 9
By default, GlassFish has no administrator password. Set a password for the GlassFish admin user for security:
sudo /opt/glassfish6/bin/asadmin --port 4848 change-admin-password
Follow the prompts to set the username and password. The default username is admin
.
Enter admin user name [default: admin]>admin
Enter the admin password>
Enter new admin password>
Enter new admin password again>
**Output**
Command change-admin-password executed successfully.
Enable secure administration to force login over HTTPS:
sudo /opt/glassfish6/bin/asadmin --port 4848 enable-secure-admin
You will be prompted for the admin username and password. The output confirms successful execution:
**Output**
Command enable-secure-admin executed successfully.
Restart GlassFish to apply the configuration changes:
sudo systemctl restart glassfish
5. Access GlasFish Admin Web Console
Access the GlassFish Admin Web Console by navigating to your server’s IP address followed by port 4848 in your web browser:
http://your-server-ip-address:4848
You will be presented with the GlassFish Admin Web Console login screen. Enter your GlassFish admin username and password to log in.
[GlassFish login screen image]
Once logged in, you’ll see the GlassFish Admin Console dashboard:
[GlassFish dashboard image]
Congratulations! You have successfully Install GlassFish on Rocky Linux 9 and configured it.
Conclusion
This guide demonstrated how to Install and Configure GlassFish on Rocky Linux 9 and access the GlassFish Admin Web Console. GlassFish provides a robust platform for deploying Java EE applications on Rocky Linux 9.
You may also be interested in these articles:
- Install Python 3.11 on Rocky Linux 9
- How To Install PHP 8.2 on Rocky Linux 9
- Install Caddy Web Server on Rocky Linux 8
- Install and Use htop command on Rocky Linux 8
Alternative Installation Methods for GlassFish on Rocky Linux 9
While the above steps outline a standard method to Install GlassFish on Rocky Linux 9, alternative approaches exist that might better suit certain environments or preferences. Here are two different ways to achieve the same goal.
1. Using Docker
Docker provides a containerized environment, offering isolation and portability. This is an excellent alternative to Install GlassFish on Rocky Linux 9 directly on the host operating system, particularly for development or testing environments.
Explanation:
Docker allows you to run GlassFish in an isolated container. This means that the GlassFish installation and its dependencies are self-contained and won’t interfere with other applications on your system. It also simplifies deployment, as you can easily move the container to different environments.
Steps:
-
Install Docker: If you haven’t already, install Docker on your Rocky Linux 9 system. Follow the official Docker documentation for installation instructions: https://docs.docker.com/engine/install/
-
Pull a GlassFish Docker Image: Use Docker Hub to find a suitable GlassFish image. A popular choice is the
payara/server-full
image, which provides a fully configured Payara Server (a GlassFish derivative).sudo docker pull payara/server-full
-
Run the GlassFish Container: Run the Docker image with the necessary port mappings. This maps ports on your host machine to the ports within the container, allowing you to access the GlassFish Admin Console and deployed applications.
sudo docker run -p 4848:4848 -p 8080:8080 -p 8181:8181 payara/server-full
This command maps port 4848 (Admin Console), 8080 (HTTP), and 8181 (HTTPS) from the container to your host.
-
Access the GlassFish Admin Console: Open your web browser and navigate to
http://your-server-ip-address:4848
. The default username isadmin
and the password isadmin
. You can change these credentials after logging in.
Advantages:
- Isolation: Prevents conflicts with other applications.
- Portability: Easily move the container to different environments.
- Reproducibility: Ensures consistent deployments across different systems.
- Simplified Setup: Avoids manual installation steps.
2. Using SDKMAN!
SDKMAN! (Software Development Kit Manager) is a tool for managing multiple versions of software development kits, including Java. While not directly installing GlassFish, it simplifies the Java setup, a critical prerequisite for Install GlassFish on Rocky Linux 9.
Explanation:
SDKMAN! provides a convenient way to install and manage Java versions without manually downloading and configuring them. This can streamline the initial setup process. While it doesn’t install GlassFish itself, it ensures you have a compatible Java version readily available.
Steps:
-
Install SDKMAN!: Follow the installation instructions on the SDKMAN! website: https://sdkman.io/install
Generally, this involves running a curl command:
curl -s "https://get.sdkman.io" | bash
Then, open a new terminal or source your
.bashrc
or.zshrc
file:source "$HOME/.sdkman/bin/sdkman-init.sh"
-
Install a Java Version: Use SDKMAN! to install a compatible Java version (e.g., Java 11):
sdk install java 11-openj9-jre
SDKMAN! will download and install the specified Java version and set it as the current default.
-
Verify Java Installation: Check the Java version using the
java -version
command. -
Proceed with Manual GlassFish Installation: After setting up Java with SDKMAN!, follow the manual installation steps outlined in the original guide (downloading the GlassFish zip file, extracting it, creating the systemd unit file, etc.).
Advantages:
- Simplified Java Management: Easily install and switch between different Java versions.
- Automated Installation: Avoids manual Java download and configuration.
- Clean Installation: Keeps Java installations separate from system-wide installations.
These alternative methods offer different approaches to setting up GlassFish on Rocky Linux 9, catering to different needs and preferences. The Docker approach provides containerization for isolation and portability, while SDKMAN! simplifies Java management. Choose the method that best aligns with your environment and requirements.