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
- AEM Installed on your server. Copy the path of the install (e.g: /mnt/crx)
- Java (atleast JRE) installed (To test if java is installed and the version, run this command
java -version
) - 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. - Create a user who will have access to the service. (e.g: aem)
Step-by-step guide
- You will need root access
- Create user aem and add to sudoers group
adduser aem
usermod -aG sudo aem
- Test the user
su - aem
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)
- aem
- aem.service
- Open
aem
script file and update the below- AEM_ROT (e.g:
/mnt/crx
is the root, where/mnt/crx/crx-quickstart
is the full path) - AEM_USER (e.g:
aem
)
- AEM_ROT (e.g:
- SCP these files to the server
- Copy
aem
to/usr/bin/aem
- Example: From terminal on your desktop
$ scp <filename> user@1.1.1.1:/usr/bin/aem
- Example: From terminal on your desktop
- Copy
aem.service
to/etc/system.d/system/aem.system
- Example: From terminal on your desktop
$ scp <filename> user@1.1.1.1:/etc/system.d/system/aem.system
- Example: From terminal on your desktop
- Copy
- SSH to your server
ssh user@1.1.1.1
- Give permissions to the files
sudo chmod u+rwx /usr/bin/aem
sudo chmod u+rwx /etc/system.d/system/aem.system
- Update
cd /etc/system.d/system
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 aem
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 thisroot 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
- The example above was tested on CentOS 7 and Ubuntu 17.04
- AEM 6.4 version was used. Although the above process should work for AEM 6.x
When you do grep it says 6.4, but you had mentioned 63. is used for install.. Am i missing something?
Thanks for pointing it out Chethy. I’ve updated the post.
on Cent OS Replace aem.system as aem.service if you get errrors like below
When I run this , I get service
# sudo systemctl enable aem.system
Failed to execute operation: No such file or directory
Is it going to work for aem 6.5 with linux
Should work. This is more of setting up an application (aem or any) on Linux.