4.9.2. Configure JBoss EAP 6 as a Service in Red Hat Enterprise Linux (Zip, Installer)

Prerequisites

Summary
Use the following procedure to install JBoss EAP 6 as a service on Red Hat Enterprise Linux when the installation has been done with either the zip, text, or graphical methods. This process does not apply when the installation has been done using the RHN (RPM) method.

Procedure 4.17. Set Up the Service

Note

The steps below describe running JBoss EAP 6 as a service in standalone mode. In order to run JBoss EAP 6 as a service in domain mode, use the same steps but replace jboss-as-standalone.sh with jboss-as-domain.sh.
  1. Locate the start-up script and configuration file

    The start-up script and an associated configuration file are located in the EAP_HOME/bin/init.d/ directory. Open the configuration file jboss-as.conf to edit it.
  2. Customize the start-up options in the jboss-as.conf file

    There are several options within the jboss-as.conf file. At the minimum, specify the correct values for JBOSS_HOME and the JBOSS_USER variables. If these variables are absent, add them.
  3. Copy files into system directories

    1. Copy the modified configuration file to the /etc/jboss-as directory.
      [user@host init.d]$ sudo mkdir /etc/jboss-as
      [user@host init.d]$ sudo cp jboss-as.conf /etc/jboss-as/
    2. Copy the start-up script to the /etc/init.d directory.
      [user@host init.d]$ sudo cp jboss-as-standalone.sh /etc/init.d
  4. Add the start-up script as a service.

    Add the new jboss-as-standalone.sh service to list of automatically started services, using the chkconfig service management command.
    [user@host init.d]$ sudo chkconfig --add jboss-as-standalone.sh
  5. Start the service.

    Test that the service has been installed correctly by using one of the following commands for Red Hat Enterprise Linux.
    • For Red Hat Enterprise Linux 5 and 6:
      [user@host bin]$ sudo service jboss-as-standalone.sh start
    • For Red Hat Enterprise Linux 7:
      [user@host bin]$ sudo service jboss-as-standalone start
    If everything has gone correctly, you should get a green [OK]. If you get an error, check the error logs and make sure your paths are correct in the configuration file.

    Note

    The green [OK] does not appear for Red Hat Enterprise Linux 7.
  6. Make the service start automatically when you restart your server.

    To add the service to the list of services which start automatically when your server restarts, issue the following command.
    [user@host init.d]$ sudo chkconfig jboss-as-standalone.sh on
Result
JBoss EAP 6 starts automatically when the Red Hat Enterprise Linux reaches its default run-level, and stops automatically when the operating system goes through its shutdown routine.

Procedure 4.18. Uninstall the JBoss EAP 6 service from Red Hat Enterprise Linux

Note

The steps below describe uninstalling the JBoss EAP 6 service in standalone mode. In order to uninstall the JBoss EAP 6 service in domain mode, use the same steps but replace jboss-as-standalone.sh with jboss-as-domain.sh.
  1. If the service is running, first open a terminal and stop the service by executing the stop command with the name of the service:
    sudo service jboss-as-standalone.sh stop
  2. Remove JBoss EAP from the list of services:
    sudo chkconfig --del jboss-as-standalone.sh
  3. Remove the system directory files.
    1. Remove the service start-up script:
      sudo rm /etc/init.d/jboss-as-standalone.sh
    2. Remove the service configuration file:
      sudo rm /etc/jboss-as/jboss-as.conf

      Important

      /etc/jboss-as is not a standard system directory. Only if there are no other files being used there, also remove the directory itself:
      sudo rm -rf /etc/jboss-as/
Result
JBoss EAP 6 service is uninstalled from the server.