How to Install Wildfly in virtual server running in VirtualBox Application using CentOS 8

Posted on

Introduction

This article is an article about how to install Wildfly Application Server. The process for installing the Wildfly Application Server is in a virtual server running with CentOS 8 as its operating system. The virtual server is running under a VirtualBox application. In order to install it, this article is referring to another article available in this link. That article has a title of ‘How to Install Wildfly on CentOS 8’. For installing Wildfly Application Server, there are several steps to fulfill it. It consists of preparation part and the latter is the installation and the configuration part. Below are the explanation for each parts.

Preparation Part for Installing Wildfly Application Server

The first part is about preparing the Wildfly Application Server. Those steps exist in the following sequence :

  1. Just start the VirtualBox application. It is the first step where the following image will appear :

    How to Install Wildfly in virtual server running in VirtualBox Application using CentOS 8
    How to Install Wildfly in virtual server running in VirtualBox Application using CentOS 8
  2. Next step, just run the virtual server. In the above image, it is a virtual server with the label of ‘CentOS-8’. Accessing the virtual server after running it is possible by direct or remote access. Accessing remotely, it is possible for using a certain method such as SSH connection. As a reference, just read the article with the title ‘How to Remote CentOS Virtual Server running in a VirtualBox with a NAT Network using SSH’ in this link.

  3. After successfully access the virtual server, prepare the command line interface. Following after, just download the Wildfly Application Server  installer. Just use any available tools available in the virtual server for downloading the Wildfly Application Server installer. In this article, the download process is using ‘wget’ tool. The following is the command execution :

    [root@10 ~]# wget https://download.jboss.org/wildfly/23.0.0.Final/wildfly-23.0.0.Final.tar.gz
    --2021-03-28 11:12:39--  https://download.jboss.org/wildfly/23.0.0.Final/wildfly-23.0.0.Final.tar.gz
    Resolving download.jboss.org (download.jboss.org)... 23.75.23.242, 23.75.23.113, 2600:1417:3f::173d:cd58, ...
    Connecting to download.jboss.org (download.jboss.org)|23.75.23.242|:443... connected.
    HTTP request sent, awaiting response... 200 OK
    Length: 208388125 (199M) [application/x-gzip]
    Saving to: ‘wildfly-23.0.0.Final.tar.gz’
    
    wildfly-23.0.0.Final.tar.gz        100%[========================================================================================>] 198.73M  1.18MB/s    in 2m 56s
    
    2021-03-28 11:15:35 (1.13 MB/s) - ‘wildfly-23.0.0.Final.tar.gz’ saved [208388125/208388125]
    
    [root@10 ~]#
  4. Extract the installer of Wildfly Application Server in the following command execution :

    [root@10 temp]# tar -zxvf wildfly-23.0.0.Final.tar.gz
    wildfly-23.0.0.Final/
    wildfly-23.0.0.Final/appclient/
    wildfly-23.0.0.Final/appclient/configuration/
    wildfly-23.0.0.Final/.installation/
    wildfly-23.0.0.Final/.well-known/
    wildfly-23.0.0.Final/.well-known/acme-challenge/
    wildfly-23.0.0.Final/domain/
    wildfly-23.0.0.Final/domain/configuration/
    wildfly-23.0.0.Final/domain/tmp/
    wildfly-23.0.0.Final/domain/tmp/auth/
    wildfly-23.0.0.Final/docs/
    wildfly-23.0.0.Final/docs/examples/
    wildfly-23.0.0.Final/docs/examples/configs/
    wildfly-23.0.0.Final/docs/schema/
    wildfly-23.0.0.Final/docs/contrib/
    wildfly-23.0.0.Final/docs/contrib/scripts/
    wildfly-23.0.0.Final/docs/contrib/scripts/service/
    wildfly-23.0.0.Final/docs/contrib/scripts/service/amd64/
    wildfly-23.0.0.Final/docs/contrib/scripts/systemd/
    wildfly-23.0.0.Final/docs/contrib/scripts/init.d/
    wildfly-23.0.0.Final/docs/licenses/
    wildfly-23.0.0.Final/standalone/
    wildfly-23.0.0.Final/standalone/configuration/
    wildfly-23.0.0.Final/standalone/tmp/
    wildfly-23.0.0.Final/standalone/tmp/auth/
    wildfly-23.0.0.Final/standalone/deployments/
    wildfly-23.0.0.Final/standalone/lib/
    wildfly-23.0.0.Final/standalone/lib/ext/
    wildfly-23.0.0.Final/bin/
    wildfly-23.0.0.Final/bin/client/
    wildfly-23.0.0.Final/welcome-content/
    wildfly-23.0.0.Final/modules/
    wildfly-23.0.0.Final/modules/system/
    wildfly-23.0.0.Final/modules/system/layers/
    wildfly-23.0.0.Final/modules/system/layers/base/
    wildfly-23.0.0.Final/modules/system/layers/base/com/
    ...
    
  5. Next step, just copy the extracted installer of Wildfly Application Server to ‘/usr/share’. This is actually a preferred location. Sometime there are another references which is suggesting to put it in ‘/opt’. In the context of the article reference from other site with the title of ‘How to Install Wildfly on CentOS 8’ in this link, it put it in the ‘/opt’. But in this context, it is using the suggested pattern of ‘/usr/share’. Execute it as the following command :

  6. [root@10 ~]# cp -rv wildfly-23.0.0.Final/ /usr/share
    ....
    [root@10 ~]#
    
  7. Soon after, just create a new symbolic link to access the root folder or home directory of the Wildfly Application Server :

    [root@10 ~]#ln -s /usr/share/wildfly-23.0.0.Final /usr/share/wildfly
    ...
    [root@10 ~]
    
  8. Continue on the previous step, create a user for running and owning the service of the Wildfly Application Server. Just execute the following command to do it :

  9. [root@10 ~]# sudo groupadd --system wildfly
    [root@10 ~]# sudo useradd -d /usr/share/wildfly -r -s /bin/false -g wildfly wildfly
    [root@10 ~]#
    

    In another article which is served as a reference, there is another command pattern for creating a new user to manage the service.

    [root@10 ~]# groupadd -r wildfly
    [root@10 ~]# useradd -r -g wildfly -d /opt/wildfly -s /sbin/nologin wildfly
    

    But the main purpose is quite similar. The parameter -s is describing a shell for the creating of a new user. Both is aiming to disable shell for any further login attempt by that created new user.

  10. Next, execute the following command to change the ownership of the Wildfly Application Server also along with the symbolic link created in the previous step :

  11. [root@10 ~]# chown -Rv wildfly.wildfly /usr/share/wildfly 
    [root@10 ~]# chown -Rv wildfly.wildfly /usr/share/wildfly-23.0.0.Final/
    ...
    [root@10 ~]#
    

Configuration Part for Installing Wildfly Application Server

The following are the steps in order to prepare the Wildfly Application Server which is focusing on configuring Wildfly Application Server. The steps following are the steps for configuring it :

  1. In the first step, create a new file configuration in order to manage Wildfly Application Server’s service. Just execute the following command :

      
    [root@10 ~]# mkdir -p /etc/wildfly
    

    The above command is a command to create a new folder to store the Wildfly Application Server’s configuration using its base original configuration from the installer. Just copy it by executing the following command :

      
    [root@10 ~]# cp/opt/wildfly/docs/contrib/scripts/systemd/wildfly.conf /etc/wildfly/
    [root@10 ~]#
    

    The following is the content of the wildfly.conf :

    # 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
    
  2. Finally, for the file or script managing a service of Wildfly Application Server’s service, it exist in the original installer of Wildfly Application Server. Just copy it by executing the following command :

    [root@10 ~]# cp/opt/wildfly/docs/contrib/scripts/systemd/wildfly.service etc/systemd/system/
    [root@10 ~]#
    

    Just edit the file configuration of the base original file from the following original content :

    [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
    ExecStart=/usr/share/wildfly/bin/launch.sh $WILDFLY_MODE $WILDFLY_CONFIG $WILDFLY_BIND
    StandardOutput=null
    
    [Install]
    WantedBy=multi-user.target
    

    As in the above content display of the file,  change the line starts with ‘ExecStart’ accordingly. It is the main root path of Wildfly which in this context it exist in ‘/usr/share/wildfly’.

    It is a script for starting, stopping and restarting the service of Wildfly Application Server.

  3. After creating the service file, execute the following command to implement the new added service’s script :
    [root@10 ~]# systemctl daemon --reload
    [root@10 ~]# systemctl start wildfly
    [root@10 ~]# systemctl enable wildfly
    
  4. Continuing on the previous step, just access the Wildfly Application Server’s service from a web browser. The address itself exist in  localhost:8080. Since it is running in a virtual server, the access need a specific rule. It is a rule for enabling the port forwarding. This rule enabling to forward an incoming request in the host machine to the virtual machine. Wildfly Application Server is runnning on port 8080 in the virtual machine or in the guest machine side. In order to add the rule, just add any port in the host machine side. For further reference, read the article with the title of ‘How to Add Port Forwarding Rule to access Code Igniter 4 Service of Guest Machine running in VirtualBox Manager from Host Machine’ in this link to do it.

  5. Soon after, just access the Wildfly Application Server. For an example, using port ‘9080’ in the host machine to be able to reach the port 8080 in the guest machine. So, in order to access the Wildfly Application Server’s service, just access the address of ‘localhost:9080’ as available in the following image :

    How to Install Wildfly in virtual server running in VirtualBox Application using CentOS 8
    How to Install Wildfly in virtual server running in VirtualBox Application using CentOS 8

Leave a Reply