In this tutorial, we will show you how to install GlassFish on Debian 12. In the realm of web development and server management, the ability to deploy Java applications efficiently and effectively is paramount. GlassFish, a free, open-source Java application server, has emerged as a go-to solution for developers worldwide. It supports a wide array of Java-based technologies, including Enterprise JavaBeans, JavaServer Faces, JPA, and JavaServer Pages, among others.
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 the step-by-step installation of the GlassFish on a Debian 12 (Bookworm).
- A server running one of the following operating systems: Debian 12 (Bookworm).
- It’s recommended that you use a fresh OS install to prevent any potential issues.
- SSH access to the server (or just open Terminal if you’re on a desktop).
- You will need an active internet connection to download the GlassFish package.
non-root sudo useror access to the
root user. We recommend acting as a
non-root sudo user, however, as you can harm your system if you’re not careful when acting as the root.
Install GlassFish on Debian 12 Bookworm
Step 1. Before we dive into the installation process, it’s crucial to ensure that your Debian 12 system is up-to-date. This step helps avoid potential conflicts between system packages and the GlassFish server. To update your system, open the terminal and execute the following commands:
sudo apt update sudo apt upgrade
These commands will fetch the latest package lists from the repositories and upgrade any outdated packages on your system.
Step 2. Installing Java (OpenJDK).
GlassFish is a Java application server, so it requires Java to run. We’ll install OpenJDK, an open-source implementation of the Java Platform, Standard Edition. To install OpenJDK on Debian 12, use the following commands:
sudo apt install default-jdk
Verify the Java version using the following command:
Step 3. Installing GlassFish on Debian 12.
Next, we’ll download the latest version of GlassFish from the official website. You can use the
wget command to download files directly from the terminal. Replace
GLASSFISH_URL with the download link of the latest GlassFish version:
Once the download is complete, extract the GlassFish archive and move it to the desired installation directory. For instance, to extract the archive to the
/opt directory, use the following commands:
tar -xvf glassfish-*.zip -C /opt
This command will create a
glassfish directory in the
Step 4. Configuring GlassFish as a System Service.
To manage GlassFish as a system service, we need to create a
systemd service file. Open a new service file in the
/etc/systemd/system directory using a text editor:
sudo nano /etc/systemd/system/glassfish.service
In the opened file, add the following content:
[Unit] Description = GlassFish Server v5.0 After = syslog.target network.target [Service] ExecStart = /opt/glassfish5/glassfish/bin/asadmin start-domain domain1 ExecStop = /opt/glassfish5/glassfish/bin/asadmin stop-domain domain1 User = glassfish Restart = on-failure [Install] WantedBy = multi-user.target
Save and close the file. This configuration will start and stop the GlassFish server automatically when the system boots and shuts down, respectively.
Step 5. Starting and Enabling GlassFish Service.
Now, start the GlassFish service using the following command:
sudo systemctl start glassfish
To enable the GlassFish service to start automatically at system boot, use:
sudo systemctl enable glassfish
You can check the status of the GlassFish service with:
sudo systemctl status glassfish
Step 6. Configuring GlassFish Admin Password.
Next, set up an admin password for GlassFish. Navigate to the GlassFish bin directory and use the
cd /opt/glassfish5/glassfish/bin ./asadmin change-admin-password
Follow the prompts to set your new admin password.
Step 7. Testing GlassFish Installation.
To verify the successful installation of GlassFish, access the default GlassFish page using a web browser. Navigate to
http://YOUR_SERVER_IP:8080. You should see the GlassFish welcome page, confirming that the server is running correctly.
Step 8. Configuring GlassFish for Your Application.
Finally, customize GlassFish settings according to your application requirements. You can access the GlassFish Admin Console at
http://YOUR_SERVER_IP:4848 and log in with the admin credentials you set earlier.
Congratulations! You have successfully installed GlassFish. Thanks for using this tutorial to install the latest version of the GlassFish on Debian 12 Bookworm. For additional help or useful information, we recommend you check the official GlassFish website.