How to Install and Configure Wildfly Application Server on CentOS 7

Table of Contents

Introduction

WildFly formerly known as JBoss web and application server is an open source high performance web application server written in Java.

It is specially designed for high throughput and is able to handle millions of connections. WildFly is a simple, flexible, lightweight, managed application runtime that can help you build amazing applications easily. WildFly's architecture is based on pluggable subsystems, so you can easily add or remove. This will allow you to reduce the overall disk footprint and memory overhead of the server. WildFly supports two modes: a single JVM (standalone mode) and a multi-JVM (domain mode) that can be used to synchronize configuration across any number of processes and hosts.

In this tutorial we will learn how to install and configure the WildFly application server on a server running CentOS 7.

Requirements

  • A server running CentOS 7.
  • A non-root user with sudo privilege setup on your server.
  • A static IP address [example: 192.168.15.22] configured on your server.

Installing Oracle Java 8

Before starting the WildFly install, you will need to install Oracle Java 8 as a prerequisite of WildFly. You can download the latest version of Java from it's official website:

http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

Once download is complete, extract the downloaded archive to /opt/ directory:

sudo tar -xzvf jdk-8u111-linux-x64.tar.gz -C /opt/

Next, install Java with the following command:

sudo alternatives --install /usr/bin/java java /opt/jdk1.8.0_111/bin/java 2
sudo alternatives --config java

You should see the following output:

There are 3 programs which provide 'java'.

Selection    Command
-----------------------------------------------
   1           /usr/lib/jvm/java-1.7.0-openjdk-1.7.0.111-2.6.7.2.el7_2.x86_64/jre/bin/java
*+ 2           /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.111-1.b15.el7_2.x86_64/jre/bin/java
   3           /opt/jdk1.8.0_111/bin/java

Choose the latest version of Java and press enter.

You will also need to setup javac and jar commands path using alternatives:

sudo alternatives --install /usr/bin/jar jar /opt/jdk1.8.0_111/bin/jar 2
sudo alternatives --install /usr/bin/javac javac /opt/jdk1.8.0_111/bin/javac 2
sudo alternatives --set jar /opt/jdk1.8.0_111/bin/jar
sudo alternatives --set javac /opt/jdk1.8.0_111/bin/javac

Check and verify the version of Java:

sudo java -version

Output:

openjdk version "1.8.0_111"
OpenJDK Runtime Environment (build 1.8.0_111-b15)
OpenJDK 64-Bit Server VM (build 25.111-b15, mixed mode)

You will need to configure environment variables for Java for all users.

To do so, create a new file named java.sh and java.csh:

sudo nano /etc/profile.d/java.sh

Add the following lines:

if ! echo ${PATH} | grep -q /opt/jdk1.8.0_111/bin ; then
   export PATH=/opt/jdk1.8.0_111/bin:${PATH}
fi
if ! echo ${PATH} | grep -q /opt/jdk1.8.0_111/jre/bin ; then
   export PATH=/opt/jdk1.8.0_111/jre/bin:${PATH}
fi
export JAVA_HOME=/opt/jdk1.8.0_111
export JRE_HOME=/opt/jdk1.8.0_111/jre
export CLASSPATH=.:/opt/jdk1.8.0_111/lib/tools.jar:/opt/jdk1.8.0_111/jre/lib/rt.jar

Save the file and create another file:

sudo nano /etc/profile.d/java.csh

Add the following lines:

if ( "${path}" !~ */opt/jdk1.8.0_111/bin* ) then
   set path = ( /opt/jdk1.8.0_111/bin $path )
endif
if ( "${path}" !~ */opt/jdk1.8.0_111/jre/bin* ) then
    set path = ( /opt/jdk1.8.0_111/jre/bin $path )
endif
setenv JAVA_HOME /opt/jdk1.8.0_111
setenv JRE_HOME /opt/jdk1.8.0_111/jre
setenv CLASSPATH .:/opt/jdk1.8.0_111/lib/tools.jar:/opt/jdk1.8.0_111/jre/lib/rt.jar

Save the file and give proper permissions on both the file:

sudo chmod 755 /etc/profile.d/java.sh
sudo chmod 755 /etc/profile.d/java.csh

Downloading and Installing WildFly

Next you will need to download the latest version of WildFly from its official website.

You can download it using wget with the following command:

wget http://download.jboss.org/wildfly/10.1.0.Final/wildfly-10.1.0.Final.zip

Once download is complete, extract the downloaded archive to the /opt/ directory:

sudo unzip wildfly-10.1.0.Final.zip -d /opt/

Now define JBOSS_HOME and the JAVA_HOME path in the standlone.conf file:

sudo nano /opt/wildfly-10.1.0.Final/bin/standalone.conf

Add the following lines:

JBOSS_HOME="/opt/wildfly-10.1.0.Final"
JAVA_HOME="/opt/jdk1.8.0_111"

You can also set JBOSS_HOME system wide by editing /etc/profile file:

sudo nano /etc/profile

Add the following line:

JBOSS_HOME="/opt/wildfly-10.1.0.Final"

Save and close the file, when you are finished

Configuring WildFly

You will need to make some changes to standalone.xml file, if you want to access WildFly from network:

sudo  nano /opt/wildfly-10.1.0.Final/standalone/configuration/standalone.xml

Find and replace 127.0.0.1 with your IP address like 192.168.15.22:

        <wsdl-host>${jboss.bind.address:192.168.15.22}</wsdl-host>
        <inet-address value="${jboss.bind.address.management:192.168.15.22}"/>
        <inet-address value="${jboss.bind.address:192.168.15.22}"/>

Once you are done, start the server for standalone mode with the following command:

sudo /opt/wildfly-10.1.0.Final/bin/standalone.sh

Create WildFly Management User

Before accessing WildFly, you will need to create a user to access WildFly Management Console.

You can create a new user by running the add-user.sh script:

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

You will be guided through the process to add a new user:

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

Enter the details of the new user to add.
Using realm 'ManagementRealm' as discovered from the existing property files.
Username : admin
The username 'admin' is easy to guess
 Are you sure you want to add user 'admin' yes/no? yes
 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 :
What groups do you want this user to belong to? (Please enter a comma separated list, or leave blank for none)[  ]: ManagementRealm
About to add user 'admin' for realm 'ManagementRealm'
Is this correct yes/no? yes
Added user 'admin' to file '/opt/wildfly-10.1.0.Final/standalone/configuration/mgmt-users.properties'
Added user 'admin' to file '/opt/wildfly-10.1.0.Final/domain/configuration/mgmt-users.properties'
Added user 'admin' with groups ManagementRealm to file '/opt/wildfly-10.1.0.Final/standalone/configuration/mgmt-groups.properties'
Added user 'admin' with groups ManagementRealm to file '/opt/wildfly-10.1.0.Final/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 EJB calls.
yes/no? yes
To represent the user add the following to the server-identities definition <secret value="aGl0ZXNoQDEyMw==" />

Once you are done, you can proceed to the next step.

Allow WildFly through Firewall

By default WildFly runs on port 8080 and 9990, so you will need to allow this port to access WildFly from an outside network.

You can do this by running the following commands:

sudo firewall-cmd --zone=public --add-port=8080/tcp --permanent
sudo firewall-cmd --zone=public --add-port=9990/tcp --permanent
sudo firewall-cmd --reload

You are now ready to access WildFly.

Accessing WildFly

Open your web browser and type the URL http://192.168.15.22:8080, you should see the default WildFly dashboard as below:

WildFly dashboard

Next, click on Administration Console button, you will see the login screen as below:

WildFly login screen

Next, enter the new created username and password to directly access the Management Console:

WildFly Management Console

Summary

Congratulations! you have successfully installed WildFly application server on your CentOS 7. Feel free to ask me if you have any questions or ran into issues following the tutorial.

  • Thanks for write this tutorial. I have a question, why did you used Oracle java instead open jdk? The last one is integrated with centos once installed so you don't need to setup environment variables and paths.

    Atte, Marcelo.-

Log In, Add a Comment