Install and Configure Wildfly (JBoss) on Ubuntu 18.04 LTS

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. In this article, we will explain how a Ubuntu administrator can install and configure Wildfly for local and remote access.

We have run the commands and procedures mentioned in this article on a Ubuntu 18.04 LTS system.

Install Wildfly

A Ubuntu administrator can install a stable WildFly application server using the following steps carefully:

Step 1: Open the Terminal

We will be using the Ubuntu command line, the Terminal, in order to install and configure WildFly. You can open the Terminal application either through the Application Launcher search or the Ctrl+alt+T shortcut.

Step 2: Update repository index

In order to install the latest available version of 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 Ubuntu Repository

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

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

Install OpenJDK

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 group for WildFly

Run the following command to add a user who will be authorized to run the service from /opt/wildfly

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

Add User for WildFly

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 be now 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 now. 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 a the /tmp folder of your Ubuntu.

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

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 WildFly from 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 a Symlink

Step 8: Give access to 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

Change file ownership

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/

WildFly systemd configuration

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:

Edit WildFly configuration

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'

Make WildFly scripts executable

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 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: Start the WildFly service

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

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

Start WildFly

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

Another thing that will help you as a regular WildFly user 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

Ubuntu systems are by default protected by the UFW firewall. If you want that your WildFly server can be accessed remotely, you need to allow traffic on port 8080.

Run the following command to do so:

$ sudo ufw allow 8080/tcp

Configure UFW 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:

Add administrator user in WildFly

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:

Set a password

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 remote access

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

Verify user

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/

WildFly successfully installed

If you see something similar to what is shows 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

WildFly Administrator login

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:

WilsFly Admin dashboard

Managing the Administrative console remotely

In order 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 WildFly

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

Open WildFly 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

Edit 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 service

You can now access the console by entering the following URL 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 Ubuntu 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 CLI script:

$ ./jboss-cli.sh --connect

Open the Administrative Console CLI

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

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

WildFly Help

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

Check version number

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.