How to Install WildFly on Ubuntu Linux

|

|

This is a detailed guide on installing and configuring WildFly, a lightweight Java-based application runtime, on Ubuntu 20.04/18.04. The guide includes installing Java and OpenJDK, creating a service account for WildFly, downloading and configuring WildFly packages, making Wild automatically at boot time, and setting up a user account to manage the app server web console.…

This brief tutorial shows students and new users how to install WildFly (JBoss) on Ubuntu 20.04 | 18.04.

WildFly (formally JBoss) is a lightweight, fast, and highly optimized Java-based application runtime that allows you to develop incredible applications from a single IDE.

WildFly is cross-platform with a robust dashboard, making changing a setting in the application server and configuration specific and immediate—no need to browse unnecessary pages to customize your environment to fit your needs.

For more about WildFly and other related documentation, please visit its homepage.

Install OpenJDK

WildFly is written in Java and requires Java JDK to function. You install the official Oracle Java JDK or the open-source alternative called OpenJDK.

For this tutorial, we will install the open-source version of Java.

To do that, run the commands below:

sudo apt update
sudo apt install default-jdk

After installing OpenJDK above, you can run the commands below to validate that it is installed.

java -version

You should see similar lines below:

openjdk version "10.0.2" 2018-07-17
OpenJDK Runtime Environment (build 10.0.2+13-Ubuntu-1ubuntu0.18.04.4)
OpenJDK 64-Bit Server VM (build 10.0.2+13-Ubuntu-1ubuntu0.18.04.4, mixed mode)

If you see the lines above, then Java is installed and ready.

Setup WildFly User

Since this is an application server, a dedicated service account is usually recommended. Run the commands below to create a WildFly service account to manage the server.

Run the commands below to create an account and group called wildfly.

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

After that, continue below to download and configure WildFly packages.

Download and Configure WildFly

Now that you’ve installed Java JDK and created a service account for WildFly, run the commands below to download WildFly packages. At the time of this post, the current version is 16.0.0. Final.

You can check its download page to get the latest when they become available.

Using wget command, you can easily download it using the commands below:

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

After downloading, run the commands below to create the WildFly folder in the /opt directory and change its ownership to the 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 the WildFly service folder in the /etc/ directory by running the commands below.

sudo mkdir -p /etc/wildfly

Then, copy WildFly configuration files and executables into the newly created directory above and make its scripts in the /etc/wildfly/bin directory executable.

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'

After that, 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/

Now, you can use the commands below to stop and automatically enable WildFly services to start at boot time.

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

To check it started, run the commands below:

sudo systemctl status wildfly.service

You should see its status service info as shown below:

● wildfly.service - The WildFly Application Server
   Loaded: loaded (/etc/systemd/system/wildfly.service; enabled; vendor preset: enabled)
   Active: active (running) since Wed 2019-04-03 10:49:06 CDT; 17s ago
 Main PID: 2252 (launch.sh)
    Tasks: 109 (limit: 4683)
   CGroup: /system.slice/wildfly.service
           ├─2252 /bin/bash /opt/wildfly/bin/launch.sh standalone standalone.xml 0.0.0.0
           ├─2253 /bin/sh /opt/wildfly/bin/standalone.sh -c standalone.xml -b 0.0.0.0
           └─2336 java -D[Standalone] -server -Xms64m -Xmx512m -XX:MetaspaceSize=96M -XX:MaxMe

Apr 03 10:49:06 ubuntu1804 systemd[1]: Started The WildFly Application Server.

Now that you’ve downloaded and configured the WildFly service, run the commands below to create a user account that will connect and manage the app server web console.

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

You’ll be prompted. Type a to continue.

What type of user do you wish to add? 
 a) Management User (mgmt-users.properties) 
 b) Application User (application-users.properties)
(a): a

Type in a new username and create a password:

Enter the details of the new user to add.
Using realm 'ManagementRealm' as discovered from the existing property files.
Username : superadmin
Password recommendations are listed below. To modify these restrictions edit the add-user.properties configuration file.
 - The password should be different from the username
 - The password should not be one of the following restricted values {root, admin, administrator}
 - The password should contain at least 8 characters, 1 alphabetic character(s), 1 digit(s), 1 non-alphanumeric symbol(s)
Password : 
WFLYDM0102: Password should have at least 1 non-alphanumeric symbol.
Are you sure you want to use the password entered yes/no? yes

Type yes for the other options and complete the setup.

WildFly should be installed and ready.

Open your browser and browse to the server hostname or IP address followed by port #8080 (its default port).

http://localhost:8080

The admin console is at:

http://localhost:8080/console

Out of the box, the server console is restricted to the local server only. To connect remotely, Open its configuration file by running the commands below.

sudo nano /etc/wildfly/wildfly.conf

Then, add the highlighted line in the file and save.

# The configuration you want to run
WILDFLY_CONFIG=standalone.xml

# The mode you want to run
WILDFLY_MODE=standalone
# The address to bind to
WILDFLY_BIND=0.0.0.0

#WildFly Console bind 
WILDFLY_CONSOLE_BIND=0.0.0.0

After that, run the script below to create an account to log on to the admin console.

sh /opt/wildfly/bin/jboss-cli.sh --connect

You’ll be prompted to enter the account and password you created above.

Authenticating against security realm: ManagementRealm
Username: superadmin
Password: 
[standalone@localhost:9990 /]

Next, open the launch script

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

And edit the highlighted lines,

#!/bin/bash

if [ "x$WILDFLY_HOME" = "x" ]; then
    WILDFLY_HOME="/opt/wildfly"
fi

if [[ "$1" == "domain" ]]; then
    $WILDFLY_HOME/bin/domain.sh -c $2 -b $3 -bmanagement $4
else
    $WILDFLY_HOME/bin/standalone.sh -c $2 -b $3 -bmanagement $4
fi

Exit and save the file.

Restart the service.

sudo systemctl restart wildfly.service

Next, open the WildFly service by running the commands below.

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

Then, edit the highlighted line and save.

[Unit]
Description=The WildFly Application Server
After=syslog.target network.target
Before=httpd.service

[Service]
Environment=LAUNCH_JBOSS_IN_BACKGROUND=1
EnvironmentFile=-/etc/wildfly/wildfly.conf
User=wildfly
LimitNOFILE=102642
PIDFile=/var/run/wildfly/wildfly.pid
ExecStart=/opt/wildfly/bin/launch.sh $WILDFLY_MODE $WILDFLY_CONFIG $WILDFLY_BIND $WILDFLY_CONSOLE_BIND
StandardOutput=null

[Install]
WantedBy=multi-user.target

Save the file and exit.

Reload systemd and restart.

sudo systemctl daemon-reload
sudo systemctl restart wildfly.service

That’s it! You can now access the admin console remotely.

Conclusion:

This post showed you how to install WildFly on Ubuntu 20.04 | 18.04. If you find any error above, please use the form below to report.

You may also like the post below:

Like this:



3 responses to “How to Install WildFly on Ubuntu Linux”

  1. Eduardo Avatar
    Eduardo

    I have installed latest version Wildfly 22.0 final in ubuntu 20.04, and i think all these lines are no more needed ( the line WILDFLY_CONSOLE_BIND=0.0.0.0 in standalone.xml and execstart in wildfly.service come by default, so console is at localhost 9090.
    Also seems that to create an user you have to use: /opt/wildfly/bin/add-user.sh instead of /opt/wildfly/bin/jboss-cli.sh –connect

    Text to be removed/changed:

    Then admin console is at:

    http://localhost:8080/console

    Out of the box, the server console is restricted to the local server only… If you’d like to connect from a remote location, Open it’s configuration file by running the commands below…

    sudo nano /etc/wildfly/wildfly.conf

    Then add the highlighted line in the file and save..

    # The configuration you want to run
    WILDFLY_CONFIG=standalone.xml

    # The mode you want to run
    WILDFLY_MODE=standalone
    # The address to bind to
    WILDFLY_BIND=0.0.0.0

    #WildFly Console bind
    WILDFLY_CONSOLE_BIND=0.0.0.0

    After that run the script below to create an account to logon to the admin console..

    sh /opt/wildfly/bin/jboss-cli.sh –connect

    You’ll be prompted to enter the account and password you created above..

    Authenticating against security realm: ManagementRealm
    Username: superadmin
    Password:
    [standalone@localhost:9990 /]

    Next, open the launch script

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

    And edit the highlighted lines,

    #!/bin/bash

    if [ “x$WILDFLY_HOME” = “x” ]; then
    WILDFLY_HOME=”/opt/wildfly”
    fi

    if [[ “$1” == “domain” ]]; then
    $WILDFLY_HOME/bin/domain.sh -c $2 -b $3 -bmanagement $4
    else
    $WILDFLY_HOME/bin/standalone.sh -c $2 -b $3 -bmanagement $4
    fi

    Exit and save the file..

    Restart the service..

    sudo systemctl restart wildfly.service

    Next, open WildFly service by running the commands below…

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

    Then edit the highlighted line and save…

    [Unit]
    Description=The WildFly Application Server
    After=syslog.target network.target
    Before=httpd.service

    [Service]
    Environment=LAUNCH_JBOSS_IN_BACKGROUND=1
    EnvironmentFile=-/etc/wildfly/wildfly.conf
    User=wildfly
    LimitNOFILE=102642
    PIDFile=/var/run/wildfly/wildfly.pid
    ExecStart=/opt/wildfly/bin/launch.sh $WILDFLY_MODE $WILDFLY_CONFIG $WILDFLY_BIND $WILDFLY_CONSOLE_BIND
    StandardOutput=null

    [Install]
    WantedBy=multi-user.target

    Save the file and exit.

    Reload systemd and restart…

    sudo systemctl daemon-reload
    sudo systemctl restart wildfly.service

  2. bartosz Avatar
    bartosz

    it is run on raspberry pi too 🙂

  3. watchuta Avatar
    watchuta

    we having wildfly-16 running in domain mode on RHEL 7.6, java 1.8.
    after a recent OS upgrade, we see java version is java-11. host-controller and process-controller is start no issues but server-group is not connecting to host-controller. What is weird is that all of the above (host-, process, & server group) are all installed on a single linux VM.
    There is no 2nd java version installed, and for that reason, we don’t use JAVA_HOME=”/usr/…” in domain.conf.
    Even if we add JAVA_HOME=.. it still changes nothing.
    I read that wildfly-16 can run on java 11 in classpath mode, but not see how to start wildfly in classpath mode. please to advising me?

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.