May 8, 2020
Estimated Post Reading Time ~

How-to Install and Start AEM As A Linux Service

This post details on how-to setup AEM as a Service on Linux. Used CentOS 7 and Ubuntu 17.04 as an example.

Github project: https://github.com/ksurendra/aem-as-a-service

Pre-requisites
  1. AEM Installed on your server. Copy the path of the install (e.g: /mnt/crx)
  2. Java (atleast JRE) installed (To test if java is installed and the version, run this command java -version)
  3. Start AEM (e.g java -jar cq-quickstart-author-p4502.jar) once. This will generate all the necessary folders, especially /mnt/crx/crx-quickstart/bin that is required by the scripts.
  4. Create a user who will have access to the service. (e.g: arm)
Step-by-step guide
  • You will need root access
  • Create user aem and add to sudoers group
  1. adduser aem
  2. usermod -aG sudo aem
  3. Test the user
  4. su - aem
  5. sudo ls -la /root [This is accessible by root only]
  • Create these 2 files (Get the contents of the files based on the OS. Under /centos or /ubutnu in this project)
  1. aem
  2. aem.service
  • Open aem script file and update the below
  1. AEM_ROT (e.g: /mnt/crx is the root, where /mnt/crx/crx-quickstart is the full path)
  2. AEM_USER (e.g: aem)
  • SCP these files to the server
  1. Copy aem to /usr/bin/aem
  2. Example: From terminal on your desktop $ scp <filename> user@1.1.1.1:/usr/bin/aem
  3. Copy aem.service to /etc/system.d/system/aem.system
  4. Example: From terminal on your desktop $ scp <filename> user@1.1.1.1:/etc/system.d/system/aem.system
  • SSH to your server
  1. ssh user@1.1.1.1
  • Give permissions to the files
  1. sudo chmod u+rwx /usr/bin/aem
  2. sudo chmod u+rwx /etc/system.d/system/aem.system
  • Update
  1. cd /etc/system.d/system
  2. sudo systemctl enable aem.system
  • You can restart the server or run the below commands to start AEM. Make sure you run Pre-requisite Step 2before running this command.
Commands to START, RESTART and STOP AEM
Centos
Start AEM – sudo service aem start
Restart AEM – sudo service aem restart
Stop AEM – sudo service aem stop
Check Status of the service sudo service aem status

Ubuntu
Start AEM – sudo systemctl start aem
Restart AEM – sudo systemctl restart aem
Stop AEM – sudo systemctlstop aem
Check Status of AEM sudo systemctl status arm

Test if AEM is running
There are several ways we can test if AEM is running with the above commands
  • Run the command ps -ef | grep java , you should see something like this
  1. root 12958 1 5 20:39 ? 00:02:41 java -server -Xmx1024m -XX:MaxPermSize=256M -Djava.awt.headless=true -Dsling.run.modes=author,crx3,crx3tar -Djava.locale.providers=CLDR,JRE,SPI -jar crx-quickstart/app/cq-quickstart-6.4.0-standalone-quickstart.jar start -c crx-quickstart -i launchpad -p 4502 -Dsling.properties=conf/sling.properties
  • Test AEM in browser http://<vm-ip-address>:4502
Troubleshooting
If the command shows active and still AEM does not load (On a browser http://localhost:4502) then check the AEM logs
  • Path for the log file: /<aem-folder>/crx-quickstart/logs/stdout.log
Notes
  1. The example above was tested on CentOS 7 and Ubuntu 17.04
  2. AEM 6.4 version was used. Although the above process should work for AEM 6.x


By aem4beginner

No comments:

Post a Comment

If you have any doubts or questions, please let us know.