Atlantic.Net Blog

How to Install Wildfly Server on Arch Linux

WildFly, formerly known as JBoss Application Server, is an open-source web application server used to build amazing applications. It is popular among users and developers worldwide who want to develop enterprise-grade Java applications. WildFly provides necessary features that reduce development time, manage resources more efficiently, and save money for users.

In this tutorial, we will explain how to install Wildfly on Arch Linux.

Step 1 – Configure Repository

By default, the default repository is outdated in Arch Linux, so you will need to modify the default mirror list if you have not done so already. You can do it by editing the mirror list configuration file:

nano  /etc/pacman.d/mirrorlist

Remove all lines and add the following lines:

## Score: 0.7, United States
Server = http://mirror.us.leaseweb.net/archlinux/$repo/os/$arch
## Score: 0.8, United States
Server = http://lug.mtu.edu/archlinux/$repo/os/$arch
Server = http://mirror.nl.leaseweb.net/archlinux/$repo/os/$arch
## Score: 0.9, United Kingdom
Server = http://mirror.bytemark.co.uk/archlinux/$repo/os/$arch
## Score: 1.5, United Kingdom
Server = http://mirrors.manchester.m247.com/arch-linux/$repo/os/$arch
Server = http://archlinux.dcc.fc.up.pt/$repo/os/$arch
## Score: 6.6, United States
Server = http://mirror.cs.pitt.edu/archlinux/$repo/os/$arch
## Score: 6.7, United States
Server = http://mirrors.acm.wpi.edu/archlinux/$repo/os/$arch
## Score: 6.8, United States
Server = http://ftp.osuosl.org/pub/archlinux/$repo/os/$arch
## Score: 7.1, India
Server = http://mirror.cse.iitk.ac.in/archlinux/$repo/os/$arch
## Score: 10.1, United States
Server = http://mirrors.xmission.com/archlinux/$repo/os/$arch

Save and close the file, then update all the package indexes with the following command:

pacman -Syu

Step 2 – Install Java

WildFly is a Java-based application server, so you will require Java to be installed on your server. You can install the latest version of Java using the following command.

pacman -S jre17-openjdk

Once installed, verify the Java installation using the following command.

java --version

You should see the Java version in the following output.

openjdk 17.0.6 2023-01-17
OpenJDK Runtime Environment (build 17.0.6+10)
OpenJDK 64-Bit Server VM (build 17.0.6+10, mixed mode)

Step 3 – Download and Install Wildfly

Before starting, it is a good idea to create a dedicated user and group to run the Wildfly application server. You can create a user and group with the following command.

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

Next, download the latest version of Wildfly using the following command.

wget https://github.com/wildfly/wildfly/releases/download/26.1.3.Final/wildfly-26.1.3.Final.zip

Once the download is completed, unzip the downloaded file with the following command.

pacman -S unzip
unzip wildfly-26.1.3.Final.zip

Next, move the extracted directory to /opt with the following command.

mv wildfly-26.1.3.Final /opt/wildfly

Next, change the ownership of the Wildfly directory.

chown -RH wildfly: /opt/wildfly

Step 4 – Configure Wildfly

First, create a configuration directory for Wildfly using the following command.

mkdir -p /etc/wildfly

Next, copy the Wildfly configuration file to the /etc/wildfly.

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

Next, edit the Wildfly configuration file.

nano /etc/wildfly/wildfly.conf

Change the file as shown below:

# 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=0.0.0.0

Next, copy the launch.sh file to the bin directory.

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

Next, edit the launch.sh file.

nano /opt/wildfly/bin/launch.sh

Find the following lines:

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

Replace them with the following lines:

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

Save and close the file when you are done.

Step 5 – Configure Systemd Service File for Wildfly

First, copy the Wildfly sample configuration file.

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

Next, edit the Wildfly service file and make some changes.

nano /etc/systemd/system/wildfly.service

Find the following line.

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

Replace it with the following line.

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

Save and close the file, then set the execution permission.

chmod +x /opt/wildfly/bin/*.sh

Next, reload the systemd daemon to apply the changes.

systemctl daemon-reload

Next, start and enable the Wildfly service with the following command.

systemctl start wildfly
systemctl enable wildfly

You can verify the Wildfly status using the following command.

systemctl status wildfly

You will get the following output.

● wildfly.service - The WildFly Application Server
     Loaded: loaded (/etc/systemd/system/wildfly.service; disabled; preset: disabled)
     Active: active (running) since Mon 2023-02-06 13:42:44 UTC; 6s ago
   Main PID: 45915 (launch.sh)
      Tasks: 118 (limit: 4700)
     Memory: 254.2M
     CGroup: /system.slice/wildfly.service
             ├─45915 /bin/bash /opt/wildfly/bin/launch.sh standalone standalone.xml 0.0.0.0
             ├─45918 /bin/sh /opt/wildfly/bin/standalone.sh -c standalone.xml -b 0.0.0.0
             └─46106 java "-D[Standalone]" -server -Xms64m -Xmx512m -XX:MetaspaceSize=96M -XX:MaxMetaspaceSize=256m -Djava.net.preferIPv4Stac>

Feb 06 13:42:44 archlinux systemd[1]: Started The WildFly Application Server.

Step 6 – Add Wildfly Admin User

Next, you will need to add an administrator user to manage the Wildfly. You can add it with the following command.

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

You will be asked to select the user types as shown below:

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

Type a for management user and press the Enter key. You will be asked to provide a username and password as shown below.

Enter the details of the new user to add.
Using realm 'ManagementRealm' as discovered from the existing property files.
Username : hjethva
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 : 
Re-enter Password : 

Provide your username and password and press the Enter key. Answer all the questions to add a user.

What groups do you want this user to belong to? (Please enter a comma separated list, or leave blank for none)[  ]: 
About to add user 'hjethva' for realm 'ManagementRealm'
Is this correct yes/no? yes
Added user 'hjethva' to file '/opt/wildfly/standalone/configuration/mgmt-users.properties'
Added user 'hjethva' to file '/opt/wildfly/domain/configuration/mgmt-users.properties'
Added user 'hjethva' with groups  to file '/opt/wildfly/standalone/configuration/mgmt-groups.properties'
Added user 'hjethva' with groups  to file '/opt/wildfly/domain/configuration/mgmt-groups.properties'
Is this new user going to be used for one AS process to connect to another AS process? 
e.g. for a slave host controller connecting to the master or for a Remoting connection for server to server Jakarta Enterprise Beans calls.
yes/no? yes

Step 7 – Access Wildfly Web Interface

Now, open your web browser and type the URL http://your-server-ip:8080 to access the Wildfly. You should see the following screen.

Wildfly default screen
You can also access the administration console using the URL http://your-server-ip:9990/console. You will be redirected to the Wildfly login screen.
Wildfly login screen
Provide your username and password and click on the Sign in button. You should see the Wildfly administrative dashboard on the following screen.
Wildfly admin dashboard

Conclusion

Congratulations! You have successfully installed the Wildfly application server on Arch Linux. You can now build and deploy Java applications using the Wildfly application server. You can test the Wildfly application server on dedicated server hosting from Atlantic.Net!

Get a $250 Credit and Access to Our Free Tier!

Free Tier includes:
G3.2GB Cloud VPS a Free to Use for One Year
50 GB of Block Storage Free to Use for One Year
50 GB of Snapshots Free to Use for One Year