Configuring AEM as a Service on CentOS

0
993
Configuring AEM as a Service on CentOS
Configuring AEM as a Service on CentOS

This article details how to setup AEM as a service on CentOS/Linux

Step-by-step guide

Prerequisites:

  1. You will need root access
  2. Download these 2 files
    1. Filename: aem
      #!/bin/bash
      #
      # /etc/rc.d/init.d/aem6
      #
      #
      # # of the file to the end of the tags section must begin with a #
      # character. After the tags section, there should be a blank line.
      # This keeps normal comments in the rest of the file from being
      # mistaken for tags, should they happen to fit the pattern.>
      #
      # chkconfig: 35 85 15
      # description: This service manages the Adobe Experience Manager java process.
      # processname: aem6
      # pidfile: /crx-quickstart/conf/cq.pid# Source function library.
      . /etc/rc.d/init.d/functions

      SCRIPT_NAME=`basename $0`
      AEM_ROOT=/opt/aem6
      AEM_USER=aem

      ########
      BIN=${AEM_ROOT}/crx-quickstart/bin
      START=${BIN}/start
      STOP=${BIN}/stop
      STATUS=”${BIN}/status”

      case “$1” in
      start)
      echo -n “Starting AEM services: ”
      su – ${AEM_USER} ${START}
      touch /var/lock/subsys/$SCRIPT_NAME
      ;;
      stop)
      echo -n “Shutting down AEM services: ”
      su – ${AEM_USER} ${STOP}
      rm -f /var/lock/subsys/$SCRIPT_NAME
      ;;
      status)
      su – ${AEM_USER} ${STATUS}
      ;;
      restart)
      su – ${AEM_USER} ${STOP}
      su – ${AEM_USER} ${START}
      ;;
      reload)
      ;;
      *)
      echo “Usage: $SCRIPT_NAME {start|stop|status|reload}”
      exit 1
      ;;
      esac

    2. Filename: aem.service
      [Unit]
      Description=Adobe Experience Manager[Service]
      Type=simple
      ExecStart=/usr/bin/aem start
      ExecStop=/usr/bin/aem stop
      ExecReload=/usr/bin/aem restart
      RemainAfterExit=yes

      [Install]
      WantedBy=multi-user.target

  3. Open aem script file and update the below
    1. AEM_ROOT (e.g: /mnt/crx is the root, where /mnt/crx/crx-quickstart is the full path)
    2. AEM_USER (e.g: aem)
  4. SCP these files to the server
    1. Copy aem to /usr/bin/aem
      1. Example: From terminal on your desktop $ scp <filename> user@1.1.1.1:/usr/bin/aem
    2. Copy aem.service to /etc/system.d/system/aem.system
      1. Example: From terminal on your desktop $ scp <filename> user@1.1.1.1:/etc/system.d/system/aem.system
  5. SSH to your server
    1. ssh user@1.1.1.1
  6. Give permissions to the files
    1. sudo chmod u+rwx /usr/bin/aem
    2. sudo chmod u+rwx /etc/system.d/system/aem.system
  7. Update
    1. cd /etc/system.d/system
    2. systemctl enable aem.system
  8. You can restart the server or run the below commands to start AEM. Make sure you run Pre-requisite Step 2 before running this command.

Commands to START, RESTART and STOP AEM

  • Start AEM – sudo service aem start
  • Restart AEM – sudo service aem restart
  • Stop AEM – sudo service aem stop

Notes

  • The example above was tested on CentOS 7
  • AEM 6.3 version was used. Although the above process should work for AEM 6.x

LEAVE A REPLY

Please enter your comment!
Please enter your name here