Share your love
How To Install GlassFish on AlmaLinux 9
In this article, we want to teach you How To Install GlassFish on AlmaLinux 9.
GlassFish is an open-source application server project started by Sun Microsystems for the Java EE platform and is now sponsored by Oracle Corporation. The supported version is called Oracle GlassFish Server. GlassFish is free software, dual-licensed under two free software licenses: the Common Development and Distribution License and the GNU General Public License with the classpath exception.
Steps To Install and Configure GlassFish on AlmaLinux 9
To complete this guide, you must log in to your server as a non-root user with sudo privileges and set up a basic firewall. To do this, you can follow our guide the Initial Server Setup with AlmaLinux 9.
Installing Java on AlmaLinux 9
To set up GlassFish on AlmaLinux 9, you need Java installed on your server. First, update your local package index with the following command:
sudo dnf update
Then, you need to install the Epel release on your server with the command below:
sudo dnf install epel-release
Now install Java on AlmaLinux 9 with the following command:
sudo dnf install java-11-openjdk-devel
When your installation is completed, verify your Java installation by checking its version:
java -version
In your output you will see:
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)
Set up GlassFish on AlmaLinux 9
To install GlassFish, you need to create a user for your GlassFish with the following command:
sudo useradd -s /sbin/nologin glassfish
Now check the latest version of GlassFish from the GlassFish Downloads Page.
Then, you need to download the GlassFish installer with the following command:
sudo wget https://download.eclipse.org/ee4j/glassfish/glassfish-6.2.5.zip
Remember to replace the version of GlassFish that you have checked in the above command.
Extract your downloaded file with the command below:
sudo unzip -d /opt/ glassfish-6.2.5.zip
Here you need to set the correct permissions for the GlassFish user with the following command:
sudo chown -R glassfish:glassfish /opt/glassfish6/
Create Systemd Unit File For GlassFish
Next, you need to create a systemd unit file for GlassFish. Create and open the file with your favorite text editor, here we use vi:
sudo vi /usr/lib/systemd/system/glassfish.service
Add the following contents 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
When you are done, save and close the file.
reload the systemd
daemon to apply the new changes with the following command:
sudo systemctl daemon-reload
Then, start your GlassFish service on AlmaLinux 9 with the following command:
sudo systemctl start glassfish
To enable GlassFish to start at boot run the following command:
sudo systemctl enable glassfish
Now you can check that your GlassFish service is active and running on AlmaLinux 9 with the command below:
sudo systemctl status glassfish
In your output you will see:
Output ● glassfish.service - GlassFish Server v6.2.5 Loaded: loaded (/usr/lib/systemd/system/glassfish.service; enabled; vendor> Active: active (running) since Mon 2022-09-26 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 ...
Configure GlassFish on AlmaLinux 9
We assumed that you have enabled firewalld from the requirements. At this point, you need to allow GlassFish ports on the AlmaLinux firewall with the command below:
sudo firewall-cmd --add-port={4848,8080,8181}/tcp --permanent
Then, reload the firewall to apply the new rules:
sudo firewall-cmd --reload
By default, GlassFish has no password. For more security, you need to set a password for the GlassFish admin user. To do this, run the following command:
sudo /opt/glassfish6/bin/asadmin --port 4848 change-admin-password
You will be asked to set the admin username as shown below:
Enter admin user name [default: admin]>admin
Next, you will be asked to enter the existing admin password, just press enter to continue:
Enter the admin password>
Here you will be asked to enter the new admin password. Enter your password and press enter. In your output you will see:
Output
Command change-admin-password executed successfully.
It’s recommended to enable secure login for the GlassFish admin console with the following command:
sudo /opt/glassfish6/bin/asadmin --port 4848 enable-secure-admin
You need to enter your username and password, in your output you will see:
Output
Command enable-secure-admin executed successfully.
Restart your GlassFish on AlmaLinux 9 to apply the changes:
sudo systemctl restart glassfish
Access GlasFish Admin Web Console
At this point, you can access the GlassFish admin console by typing your server’s IP address in your web browser followed by 4848:
http://your-server-ip-address:4848
You will see the GlassFish Administration console login screen. Enter your GLassFish admin username and password and click Login.
Now you can see your GlassFish Admin console on AlmaLinux 9.
That’s it, you are done.
Conclusion
At this point, you have learned to Install and Configure GlassFish on AlmaLinux 9.
Hope you enjoy it.
You may be like these articles:
How To Install VirtualBox on AlmaLinux 8