How to Install and Configure WildFly (JBoss) on Debian 10

WildFly, formerly known as JBoss, is a free, open-source, and cross-platform application server which is now developed by Red Hat. WildFly is written in Java and helps you in building great applications. With its pluggable subsystems, you can configure the application as and when you need it. In this article, we will explain how a Debian administrator can install and configure Wildfly on their system.

We have run the commands and procedures mentioned in this article on a Debian 10 Buster system.

Install WildFly

A Debian administrator/(sudo user) can install a stable WildFly application server using the following steps carefully:

Step 1: Open the Terminal or connect to the server by SSH

We will be using the Debian command line, the Terminal, in order to install and configure WildFly. You can open the Terminal application through the Application Launcher search as follows:

Debian Terminal

Step 2: Update repository index

In order to install the latest available version of a software from the Internet repositories, your local repository index needs to be in line with them. Run the following command as sudo in order to update your local repository index:

$ sudo apt-get update

Update package lists

Please note that only an authorized user can add, remove and configure software on Debian.

Step 3: Install the OpenJDK package from APT

Please run the following command as sudo in order to install OpenJDK from the APT repositories:

$ sudo apt-get install default-jdk

Install Java Development Kit

The system might ask you the password for sudo and also provide you with a Y/n option to continue the installation. Enter Y and then hit Enter.

Step 4: Create a user and group for WildFly

As a preliminary step, you need to create a user and group that will later be used to run the WildFly service.

Run the following command to create a new group:

$ sudo groupadd -r wildfly

Add Wildfly group

Run the following command that will be authorized to run the service at /opt/wildfly

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

Add Wildfly user

Tip: You will need to use some long commands during the installation of WildFly. Instead of typing a command, you can copy it from here and paste in the Terminal by using the Ctrl+Shift+V, or by using the Paste option from the right-click menu.

Step 5: Download the Wildfly Installation file

We will now be downloading the tar.gz for WildFly from the official JBoss website.

First, let us create a variable to define the version number of WildFly that we would like to download.

$ Version_Number=16.0.0.Final

I want to download version 16.0.0.Final on my system. This variable can be used in all the commands where you need to specify the WildFly version.

Run the following command to download the tar.gz file to the /tmp folder of your Debian.

$ wget https://download.jboss.org/wildfly/$Version_Number/wildfly-$Version_Number.tar.gz -P /tmp

Download Wildfly source code

Step 6: Extract the WildFly tar.gz file to /opt folder

The WildFly software will be installed once you extract the downloaded .tar.gz file. Run the following command as sudo in order to extract the file to the /opt folder.

$ sudo tar xf /tmp/wildfly-$Version_Number.tar.gz -C /opt/

Extract the archive

Step 7: Create a symbolic link to point to the WildFly installation directory

Run the following command to create a symbolic link by the name of wildfly. This link will point to the Wildfly installation directory.

$ sudo ln -s /opt/wildfly-$Version_Number /opt/wildfly

Create symlink

Step 8: Give access to the wildfly group and user

The WildFly user and group need ownership over the WildFly installation directory so that they can access and run WildFly.

Run the following command to do so:

$ sudo chown -RH wildfly: /opt/wildfly

Set correct file and folder permissions

Step 9: Configure Wildfly to be run as a service

Please follow these steps carefully so that you can configure WildFly to be run as a Systemd service:

1. Create a directory where we will copy the wildfly.conf file. This file is a part of the WildFly package that you downloaded and installed.

$ sudo mkdir -p /etc/wildfly

2. Copy the wildfly.conf file from the package files to the newly created directory through the following command:

$ sudo cp /opt/wildfly/docs/contrib/scripts/systemd/wildfly.conf /etc/wildfly/

Copy Wildfly config file

3. Open the configuration file in the Nano editor through the following command:

$ sudo nano /etc/wildfly/wildfly.conf

You can, of course, use any of your favorite text editors too.

This is how the file looks like:

wildfly.conf opened in nano editor

This file, for now, includes the basic configuration for a standalone system. We will later explain how to edit this file for customized configurations such as while trying to access the administrative console remotely.

4. Next, copy the launch.sh script from the WildFly package to the /opt/wildfly/bin/ folder:

$ sudo cp /opt/wildfly/docs/contrib/scripts/systemd/launch.sh /opt/wildfly/bin/

Also, make the script executable through the following command:

$ sudo sh -c 'chmod +x /opt/wildfly/bin/*.sh'

Wildfly launch script

5. The last file to copy is the wildfly.service unit file to your system’s services folder /etc/systemd/system

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

Copy systemd service file

6. Finally, you have to inform your system that you have added a new unit file. This can be done by reloading the systemctl daemon:

$ sudo systemctl daemon-reload

Reload systemd

You are now ready to run the WildFly service as an administrator.

Step 10: Run the WildFly service

Now the WildFly service can be run like any other service recognized by Debian.

Run the following command as sudo to start the service:

$ sudo systemctl start wildfly

You can verify if all is working well by checking the status of the service as follows:

$ sudo systemctl status wildfly

Check status of wildfly service

The Active status, as highlighted above, verifies that the service is up and running.

Another thing that will help you is to enable the wildfly service at boot:

$ sudo systemctl enable wildfly

Configure Wildfly

Now that we have installed WildFly and made it run as a service, it is time to make some configurations. These basically include:

  • Adjusting your firewall
  • Creating a secure WildFly administrator
  • Verifying the successful setup
  • Accessing the WildFly administrative console, locally and remotely

Please follow these steps one-by-one so that you use the WildFly portal reliably.

Step 1: Allow traffic on port 8080

If you want that your WildFly server can be accessed remotely, you need to allow traffic on port 8080. If your Debian does not have the UFW firewall application installed by default, run the following command to install it on your system:

$ sudo apt-get install ufw

Run the following command to do so:

$ sudo ufw allow 8080/tcp

Configure the firewall

Step 2: Create a WildFly Administrator

In this step, we will be creating and configuring a WildFly user. This user will be a management user/administrator for the web-based administrative console and the CLI that can be used remotely.

Run the following command to run the add-user script from the WildFly directory:

$ sudo /opt/wildfly/bin/add-user.sh

The procedure following here is pretty much self-explanatory, but we will guide you nonetheless.

The script will first ask you if you want to create a management user or an application user:

Create Wildfly admin user

Simply hit Enter to specify that you want to create a management user.

The script will then prompt you to add details about the new user. This includes adding a username of the new admin and specifying and then re-entering the password as follows:

Create admin user script

In the above image, you can see that I created a user named “admin-wildfly”.

The next prompt will ask you if the user should be able to use the console remotely.

Allow console access

Enter y and the script will verify the user creation through the following message:

User created successfully

This user can now perform administrative functions on WildFly.

Step 3: Verify the successful setup of WindFly

Let us now verify if our WindFly server is up and running. Open your browser and enter the following URL:

http://<your_domain_or_IP_address>:8080

I am testing the setup on my localhost:

http://localhost:8080/

Access WildFly

If you see something similar to what is shown above, we can assure you that your WildFly instance is up and running.

How to Open the Administrative console through the web interface?

Enter the following URL in your browser in order to open the administrative console through the local system:

http://localhost:9990/console

Open WildFly admin console

Specify the User Name and Password of the management user you created in Step 2 of ‘Configure WildFly”. The console will open as follows when you click the OK button:

Wildfly administrator dashboard

Managing the Administrative console remotely

In order to access the Administrative Console remotely, you need to make small configurations to three WildFly files.

1. Open the wildfly.conf file through the following command:

$ sudo nano /etc/wildfly/wildfly.conf

Add the following lines to the end of the file:

# The address console to bind to

WILDFLY_CONSOLE_BIND=0.0.0.0

This is how the file should look like:

Allow remote access to admin console

Quit the file through Ctrl+X and then save the changes by hitting y and then Enter.

2. Open the launch .sh script file through the following command:

$ sudo nano /opt/wildfly/bin/launch.sh

Adjust the launch script

Change the highlighted lines to the following:

$WILDFLY_HOME/bin/domain.sh -c $2 -b $3 -bmanagement $4

else

$WILDFLY_HOME/bin/standalone.sh -c $2 -b $3 -bmanagement $4

Quit the file through Ctrl+X and then save the changes by hitting y and then Enter.

After that, restart the WildFly service through the following command:

$ sudo systemctl restart wildfly

3. Finally, edit the wildfly.service file through the following command:

$ sudo nano /etc/systemd/system/wildfly.service

Adjust the wildfly.service file

Replace the highlighted line with the following:

ExecStart=/opt/wildfly/bin/launch.sh $WILDFLY_MODE $WILDFLY_CONFIG $WILDFLY_BIND $WILDFLY_CONSOLE_BIND

Since we have changed the service unit file, let us notify the system through the following command:

$ sudo systemctl daemon-reload

Also, restart the WildFly service through the following command:

$ sudo systemctl restart wildfly

Restart Wildfly

You can now access the console by entering the following console on a remote machine:

http://<your_domain_or_IP_address>:9990/console

Please ensure that port 9990 is open for traffic on your firewall.

How to Open the Administrative Console CLI

Open your Debian Terminal and switch to the /opt/wildfly/bin folder from where we will be running the CLI script:

$ cd /opt/wildfly/bin/

Then, enter the following command to run the WildFly Administrative Console CL script:

$ ./jboss-cli.sh --connect

jboss-cli connect

You are now is the “[standalone@localhost:9990 /] console.

Enter “help” to see what all you can do here.

JBoss CLI

I will check the version number by entering the “version” command:

Check JBoss / Wildfly version details

You have successfully installed and configured WildFly on your system. You also know how to configure WildFly and your system so that you can access the Administrative console remotely.