How to Install WildFly on Ubuntu 20.04

Install WildFly on Ubuntu 20.04

In this article, we will have explained the necessary steps to install and configure WildFly on Ubuntu 20.04 LTS. Before continuing with this tutorial, make sure you are logged in as a user with sudo privileges. All the commands in this tutorial should be run as a non-root user.

WildFly (formally JBoss) is a lightweight, fast, and highly optimized Java-based application runtime that allows you to develop great applications from a single IDE. WildFly is flexible, lightweight, and it is based on pluggable subsystems that can be added or removed as needed.

Install WildFly on Ubuntu 20.04

Step 1. First, before you start installing any package on your Ubuntu server, we always recommend making sure that all system packages are updated.

sudo apt update
sudo apt upgrade

Step 2. Install Java.

Install the OpenJDK package using the following commands:

sudo apt install default-jdk

Once all necessary packages are installed, you can then check the version of Java that’s installed on your server:

java -version

Step 3. Setup WildFly User.

Now we will create a new system user and group named wildfly with home directory /opt/wildfly that will run the WildFly service:

sudo groupadd -r wildfly
sudo useradd -r -g wildfly -d /opt/wildfly -s /sbin/nologin wildfly

Step 4. Install WildFly on the Ubuntu system.

Go to WildFly’s official website and download the latest stable release of the application to your server:

cd /tmp
wget https://download.jboss.org/wildfly/16.0.0.Final/wildfly-16.0.0.Final.tar.gz

Then, run the commands below to create a WildFly folder in the/opt directory and change its ownership to WildFly service account:

tar xvf wildfly-16.0.0.Final.tar.gz
sudo mv wildfly-16.0.0.Final/ /opt/wildfly
sudo chown -RH wildfly: /opt/wildfly

Next, create a WildFly service folder in the /etc/directory:

sudo mkdir -p /etc/wildfly

After that, copy WildFly configuration files:

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 sh -c 'chmod +x /opt/wildfly/bin/*.sh'

Once done, copy its systemd file to the /etc/systemd/system/ directory by running the commands below:

sudo cp /opt/wildfly/docs/contrib/scripts/systemd/wildfly.service /etc/systemd/system/

You can verify that WildFly is running on your server using the following command:

sudo systemctl stop wildfly.service
sudo systemctl start wildfly.service
sudo systemctl enable wildfly.service

Step 5. Configure the Firewall.

Now allow traffic on port 8080 type the following command:

sudo ufw allow 8080/tcp

Step 6. Accessing WildFly on the Ubuntu system.

Open your browser and browse to the server hostname or IP address followed by port 8080:

http://Your_IP_Address:8080

Access WildFly Administration Console:

http://Your_IP_Address:8080/console

That’s all you need to do to install WildFly on Ubuntu 20.04 LTS Focal Fossa. I hope you find this quick tip helpful. For further reading on WildFly, please refer to their official knowledge base. If you have questions or suggestions, feel free to leave a comment below.