How To Install WildFly on Ubuntu 24.04 LTS
WildFly is a powerful, open-source Java application server known for its high performance and flexible architecture. It is maintained by Red Hat as part of the JBoss community and provides a fast, secure environment for running enterprise-level Java applications. This guide explains how to install WildFly on Ubuntu 24.04, set it up as a system service, and configure important security settings. By following these steps, it becomes easier to deploy and manage Java applications in both development and production environments.
Prerequisites
Before deploying WildFly on Ubuntu 24.04, ensure that the following requirements are in place:
- Ubuntu 24.04 server: A fresh or existing installation with administrative privileges (sudo access).
- Java Development Kit: WildFly requires a Java environment, typically OpenJDK 11 or higher.
- Sufficient system resources: While WildFly can function with minimal resources, allocate enough CPU, RAM, and storage for smooth performance.
- Internet connection: Adequate bandwidth is needed to download packages and updates.
- Non-root user: WildFly should run under a dedicated user to enhance security.
A solid understanding of basic Linux commands helps when troubleshooting and modifying configurations. Most steps involve using the terminal, so familiarity with command-line administration is beneficial.
Step 1: Update the System
Keeping the operating system updated guarantees the latest security patches and package improvements. Use the following commands to update the system:
sudo apt update
sudo apt upgrade -y
This command combination refreshes the package repositories and upgrades any outdated packages. Updating regularly helps reduce performance and security risks. Reboot the server if the kernel or core library updates warrant it:
sudo reboot
After the reboot, proceed to the next steps.
Step 2: Install Java OpenJDK
WildFly is a Java-based application server. Installing an appropriate Java Development Kit version is critical before deploying WildFly. The following command installs the default OpenJDK available in Ubuntu repositories:
sudo apt install default-jdk -y
Once installed, verify the Java version:
java --version
The output should display an OpenJDK version that is 11 or higher. Ensure the installation completed successfully because WildFly relies on Java for all its core functionalities. If additional JDK versions exist, set the default one using:
sudo update-alternatives --config java
Choose the Java installation preferred for your environment. Correct Java installation helps avoid deployment issues later.
Step 3: Create a Dedicated User and Group for WildFly
Running WildFly under a dedicated user prevents potential security breaches that could compromise the root account. Create a user and group named wildfly
in the /opt
directory where WildFly will reside:
sudo groupadd -r wildfly
sudo useradd -r -g wildfly -d /opt/wildfly -s /sbin/nologin wildfly
This pair of commands adds a group and user that cannot log in interactively. Installing WildFly under this user limits file and process access, contributing to a more secure environment. If the /opt/wildfly
directory does not exist yet, it will be created during the installation and configuration steps.
Step 4: Download the Latest WildFly Binary Package
The most recent stable binary can be found on the official WildFly website or its GitHub releases page. Identify the latest Final version of WildFly. As an example, use the following command to download version 27.0.0.Final to the /tmp
directory:
wget https://github.com/wildfly/wildfly/releases/download/27.0.0.Final/wildfly-27.0.0.Final.tar.gz -P /tmp
Confirm the file has been saved correctly by checking the downloaded package in the /tmp
directory. If there is a different version, simply replace the URL accordingly. Checking checksums and verifying authenticity of the files can be done for additional security.
Step 5: Extract and Move WildFly Files
The downloaded archive is a .tar.gz
file that needs extraction before installation. Change to the /tmp
directory and extract it into /opt
:
sudo tar xf /tmp/wildfly-27.0.0.Final.tar.gz -C /opt/
After extraction, create a symbolic link /opt/wildfly
pointing to the WildFly folder:
sudo ln -s /opt/wildfly-27.0.0.Final /opt/wildfly
This symlink eases version upgrades. Instead of modifying paths each time WildFly updates, only repoint the symbolic link to the new folder. Next, adjust directory ownership so the wildfly
user and group can access it:
sudo chown -RH wildfly:wildfly /opt/wildfly
The -RH
flag ensures the correct ownership of symlinks too. It is critical that all subdirectories under /opt/wildfly
belong to the wildfly
user for a smooth startup.
Step 6: Configure WildFly as a Systemd Service
Configuring WildFly as a systemd service simplifies management by enabling auto-start, stop, and status checks using standard Linux commands. This is the recommended approach on Ubuntu 24.04.
Create Configuration Directory
Begin by creating a dedicated folder for WildFly’s configuration files:
sudo mkdir -p /etc/wildfly
Using /etc/wildfly
keeps custom configuration separate from the main installation path.
Copy Configuration Files
WildFly’s archive includes sample scripts for systemd integration:
sudo cp /opt/wildfly/docs/contrib/scripts/systemd/wildfly.conf /etc/wildfly/
sudo cp /opt/wildfly/docs/contrib/scripts/systemd/launch.sh /opt/wildfly/bin/
sudo chmod +x /opt/wildfly/bin/*.sh
sudo cp /opt/wildfly/docs/contrib/scripts/systemd/wildfly.service /etc/systemd/system/
The wildfly.conf
file holds environment variables like WILDFLY_BIND
or WILDFLY_CONSOLE_BIND
. The launch.sh
script includes commands that systemd uses to start the server in either standalone or domain mode. Marking the scripts as executable ensures that systemd can run them properly.
Enable and Start the Service
Reload systemd to recognize the new service file:
sudo systemctl daemon-reload
Then enable the service so that it automatically starts on reboot:
sudo systemctl enable wildfly.service
Finally, start the service:
sudo systemctl start wildfly.service
To confirm WildFly is running, check its status:
sudo systemctl status wildfly.service
If the service does not start, possible causes include incorrect Java configuration, file ownership problems, or version mismatch. Examine error logs by running:
journalctl -u wildfly.service
Resolving any error messages reported here usually restores normal operation.
Step 7: Configure Firewall Rules
WildFly responds on port 8080 by default. To manage it remotely, port 9990 is commonly used for administration. On Ubuntu systems, UFW (Uncomplicated Firewall) is commonly employed for firewall management. Ensure these ports are open when required for remote access.
sudo ufw allow 8080/tcp
sudo ufw allow 9990/tcp
To verify these rules:
sudo ufw status
When hosting an application in production, it is often wise to restrict administrative consoles to a trusted IP address. Limiting access to port 9990 reduces the risk of unauthorized changes.
Step 8: Accessing the WildFly Administrative Console
Once WildFly is running, verify installation by pointing a browser to http://<server-ip>:8080/
. For local testing, use http://localhost:8080/
. A welcome page indicates the service is operational.
Add an Administrator User
WildFly includes a straightforward script to create administrative users. This user manages the server via a web-based console or CLI. Invoke this script:
sudo /opt/wildfly/bin/add-user.sh
Follow prompts to supply a username and password. When asked for realm and roles, provide “ManagementRealm” and “admin,” respectively, for full management privileges. Choose a strong password.
Enable Remote Management
To access the management console remotely, open http://<server-ip>:9990/
in a browser. If it fails, check whether the console bind address in /etc/wildfly/wildfly.conf
or standalone.xml
is set to 0.0.0.0
or an appropriate IP. Restart WildFly if changes are made:
sudo systemctl restart wildfly.service
Lastly, sign in with the administrative credentials created through the add-user.sh
script. This console allows deployment of applications, editing configurations, and reviewing subsystem settings.
Step 9: Securing WildFly Installation
After installing and configuring WildFly, tightening security ensures the environment remains protected from threats:
- UseStrong Passwords: Always choose complex passwords for administrator accounts, mixing uppercase, lowercase, digits, and special characters.
- Limit Console Access: Restrict remote access only to trusted IP addresses whenever feasible. Modify firewall rules or configure network security to block potential attackers.
- Disable Unnecessary Services: If not using domain mode, avoid exposing domain-related ports. Minimizing open ports reduces a server’s attack surface.
- Enable HTTPS/SSL: Where appropriate, configure TLS to secure data in transit. Generating a self-signed certificate or using a CA-signed certificate can be done through the server’s security subsystem.
A focus on security from the start avoids complications and helps avoid compliance issues for enterprise deployments.
Step 10: Testing and Verifying Installation
Verifying correct functionality confirms the server, user credentials, and firewall settings are correct. A thorough test includes:
Check Service Status
Confirm the service is active and enabled on startup:
sudo systemctl status wildfly.service
Deploy a Sample Application
Create (or download) a small Java web application (e.g., a simple hello-world.war file) and place it in the /opt/wildfly/standalone/deployments/
folder. WildFly deploys it automatically. Check the console or server logs to see if the deployment succeeded. Access the application in a browser at:
http://<server-ip>:8080/hello-world
Review Logs
Inspect the WildFly standalone/log/server.log
file for errors or warnings:
sudo tail -f /opt/wildfly/standalone/log/server.log
Continuous log monitoring helps detect configuration errors early. Look for specific exceptions or error messages that might point to library conflicts or resource constraints.
Optional: Integrate Nginx as a Reverse Proxy
For production-level setups or to serve multiple applications on the same server, a reverse proxy configuration with Nginx can simplify management.
Install Nginx
Run this command to install Nginx on Ubuntu:
sudo apt install nginx -y
Configure Nginx as a Reverse Proxy
Create a new configuration file, for example, /etc/nginx/sites-available/wildfly.conf
:
server {
listen 80;
server_name your_server_ip_or_domain;
location / {
proxy_pass http://127.0.0.1:8080/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
}
Enable the configuration by creating a symbolic link:
sudo ln -s /etc/nginx/sites-available/wildfly.conf /etc/nginx/sites-enabled/
Remove or disable the default site if it conflicts with the new configuration:
sudo rm /etc/nginx/sites-enabled/default
Then test and reload Nginx:
sudo nginx -t
sudo systemctl restart nginx
Now, requests to http://your_server_ip_or_domain/
automatically forward to the WildFly server on port 8080. This approach keeps the front-end interface on port 80 (or 443 for HTTPS) and hides the application server port from public exposure. SSL certificates and advanced caching can also be configured in Nginx.
Additional Resources and Troubleshooting Tips
- WildFly Documentation: Visit the official docs for detailed subsystem and security configuration references.
- System Logs: Check the
journalctl
logs or/var/log
directory to troubleshoot system-level issues like Java path problems or OS-level firewall conflicts. - Port Conflicts: If another process uses port 8080 or 9990, modify the offsets in
standalone.xml
or kill the conflicting process. Usesudo lsof -i :8080
to identify conflicts. - Java Home Environment: If WildFly complains about missing Java or a version mismatch, define the environment variables
JAVA_HOME
andJRE_HOME
in/etc/wildfly/wildfly.conf
. - Domain Mode vs. Standalone Mode: WildFly has a domain mode for orchestrating multiple servers. If domain mode is not intended, confirm that the
WILDFLY_MODE
variable inwildfly.conf
is set tostandalone
.
Congratulations! You have successfully installed WildFly. Thanks for using this tutorial for installing the WildFly (JBoss) on Ubuntu 24.04 LTS system. For additional help or useful information, we recommend you check the official WildFly website.