How to Install WildFly (JBoss) on CentOS 7
WildFly , formerly known as JBoss is a cross-platform open-source application runtime written in Java. WildFly is flexible, lightweight, and it is based on pluggable subsystems that can be added or removed as needed.
Install Java OpenJDK
OpenJDK is the open-source implementation of the Java Platform which is the default Java development and runtime in CentOS 7.
Install the OpenJDK package by running:
yum install java-11-openjdk-devel
You can verify the installation, by running the following command which will print the Java version:
java -version
Create a User
Running WildFly as the root user is a security risk and not considered best practice.
First, we need to create a folder to WildFly:
mkdir /opt/wildfly
We need to create a new user and group named wildfly
with home directory /opt/wildfly
:
> groupadd -r wildfly
> useradd -r -g wildfly -d /opt/wildfly -s /sbin/nologin wildfly
Install WildFly
In order to install the latest version of WildFly, please check the following link: Download WildFly.
Download the WildFly archive in the /tmp
directory using the following wget
command:
wget https://download.jboss.org/wildfly/21.0.1.Final/wildfly-21.0.1.Final.tar.gz -P /tmp
When the download is completed, unpack the tar.gz file and move it to the /opt
directory:
tar xf /tmp/wildfly-21.0.1.Final.tar.gz -C /opt/
Next, create a symbolic link wildfly
that will point to the WildFly installation directory:
ln -s /opt/wildfly-21.0.1.Final /opt/wildfly
WildFly will run under the wildfly
user which needs to have access to the WildFly installation directory.
Change the directory ownership to user and group wildfly
with the following chown command :
chown -RH wildfly: /opt/wildfly
Configure Systemd
1 – First, we need to create a directory which will hold the WildFly configuration file:
mkdir -p /etc/wildfly
2 – Then, copy the configuration file to that /etc/wildfly
directory:
cp /opt/wildfly/docs/contrib/scripts/systemd/wildfly.conf /etc/wildfly/
This file allows you to specify the WildFly mode and bind address.
By default, WildFly will run in a standalone mode and will listen on all interfaces.
You can edit the file according to your needs.
3 – Next, copy the WildFly launch.sh
script to the /opt/wildfly/bin/
directory:
cp /opt/wildfly/docs/contrib/scripts/systemd/launch.sh /opt/wildfly/bin/
The scripts inside bin
directory must have executable flag:
sh -c 'chmod +x /opt/wildfly/bin/*.sh'
4 – Copy the systemd unit file named to the /etc/systemd/system/
directory:
cp /opt/wildfly/docs/contrib/scripts/systemd/wildfly.service /etc/systemd/system/
Notify systemd that we created a new unit file:
systemctl daemon-reload
5 – Start the WildFly service an enable it to be automatically started at boot time by running:
systemctl start wildfly
systemctl enable wildfly
6 – Verify that the service is running:
systemctl status wildfly
Open the firewall port for the WildFly
we need to open the following port to be able to access the WildFly from outside:
firewall-cmd --zone=public --permanent --add-port=8080/tcp
firewall-cmd --reload
Test the WildFly Installation
To access the default WildFly page, open your browser and type: http://<your_domain_or_IP_address>:8080
Configure WildFly Authentication
Now that WildFly is installed and running the next step is to create a user who will be able to connect using the administration console or remotely using the CLI.
To add a new user use the add-user.sh
script that is located the WildFly’s bin directory:
/opt/wildfly/bin/add-user.sh
You’ll be asked what type of user do you wish to add
Select a
and hit Enter
:
Next, the script will prompt you to enter the details of the new user.
Access WildFly Administration Console
Command-Line Interface
To access the WildFly Administration Console from the command line you can use the jboss-cli.sh
script.
Navigate to the WildFly’s bin directory and run the script with the --connect
option:
cd /opt/wildfly/bin/
./jboss-cli.sh --connect
You will be asked to enter your administrative username and passwor.ز
Once you login the console prompt will change to [standalone@localhost:9990 /]
. Type help
to get a list of commands and command syntax.
Web Interface
If you prefer to manage your server from the GUI, WildFly also provides a web-based console.
By default, the WildFly administration console is available only from localhost at http://localhost:9990/console
.
If you want to access the console from remote locations you’ll need to make small modifications to the wildfly.service
, wildfly.conf
and launch.sh
files.
1 – Open the wildfly.conf
and append WILDFLY_CONSOLE_BIND=0.0.0.0
at the end of the file.
2 – Open the launch.sh
and edit the highlighted lines:
Restart the service for changes to take effect:
systemctl restart wildfly
3 – Open the wildfly.service
and edit the ExecStart=
line as following:
ExecStart=/opt/wildfly/bin/launch.sh $WILDFLY_MODE $WILDFLY_CONFIG $WILDFLY_BIND $WILDFLY_CONSOLE_BIND
4 – Create the /var/run/wildfly
directory and set correct permissions:
mkdir /var/run/wildfly/
chown wildfly: /var/run/wildfly/
5 – Notify systemd that the unit file was changed and restart the service:
systemctl daemon-reload
systemctl restart wildfly
6 – Open the WildFly management port in the firewall:
firewall-cmd --zone=public --permanent --add-port=9990/tcp
firewall-cmd --reload
Now, you should be able to access the WildFly administration console at http://<your_domain_or_IP_address>:9990/console
.
12 Comments
Hurrah! Finally I got a web site from where I can truly obtain valuable information regarding my study and knowledge. Son Ocano
A person essentially assist to make seriously posts I might state. Royal Bradtke
Remarkable! Its really amazing post, I have got much clear idea regarding from this paragraph. Johnathon Resendes
This paragraph is truly a good one it helps new web people, who are wishing in favor of blogging. Jesse Hanauer
Pretty! This was an extremely wonderful post. Many thanks for supplying this info. Jordon Glauberman
Thank you for your blog. Much thanks again. Really Cool. Barney Drozdowski
Fabulous, what a weblog it is! This blog gives useful information to us, keep it up. Kieth Beatley
You should be a part of a contest for one of the finest blogs on the internet. Lemuel Barnet
Pretty! This was an incredibly wonderful article. Thanks for providing this info. Jerald Pitzer
Its good as your other content :D, regards for putting up. Eloy Grines
Pretty! This was an extremely wonderful post. Thanks for supplying this info. Aubrey Hollings
There is definately a great deal to find out about this issue. I really like all of the points you have made. Lucius Suoboda