Skip to content

Instantly share code, notes, and snippets.

@jverweijL
Last active July 19, 2023 13:02
Show Gist options
  • Save jverweijL/a077dffd164fd2659963d4431e029439 to your computer and use it in GitHub Desktop.
Save jverweijL/a077dffd164fd2659963d4431e029439 to your computer and use it in GitHub Desktop.
Install Liferay as a Service on Ubuntu 16.04
sudo nano /etc/systemd/system/liferay.service

Add the following contents (make sure to user your own paths)

[Unit]
Description=Liferay Apache Tomcat Web Application Container
After=network.target

[Service]
Type=forking
#Environment=JAVA_HOME=/usr/lib/jvm/java-8-oracle
#Environment=CATALINA_PID=/opt/liferay-dxp-7.2.10-ga1/tomcat-9.0.17/temp/tomcat.pid
#Environment=CATALINA_HOME=/opt/liferay-dxp-7.2.10-ga1/tomcat-9.0.17
#Environment=CATALINA_BASE=/opt/liferay-dxp-7.2.10-ga1/tomcat-9.0.17
#Environment='CATALINA_OPTS=-Xms1024M -Xmx2048M -server -XX:+UseParallelGC'
#Environment='JAVA_OPTS=-Djava.awt.headless=true -Djava.security.egd=file:/dev/./urandom'

ExecStart=/opt/liferay-dxp-7.2.10-ga1/tomcat-9.0.17/bin/startup.sh
ExecStop=/opt/liferay-dxp-7.2.10-ga1/tomcat-9.0.17/bin/shutdown.sh

User=ubuntu
Group=ubuntu
#UMask=0007
#RestartSec=10
#Restart=always

[Install]
WantedBy=multi-user.target

When you are finished, save and close the file.

Next, reload the systemd daemon so that it knows about our service file:

sudo systemctl daemon-reload

Now enable the service

sudo systemctl enable liferay

Start the Liferay service by typing:

sudo systemctl start liferay

Double check that it started without errors by typing:

sudo systemctl status liferay
@MangoSeed
Copy link

Thank you very much! Helped me a lot!

@israelblanco
Copy link

It works

@sab01bensalem
Copy link

I can't start the service I got this message :
Process: 8712 ExecStart=/var/www/vhosts/themeray.com/liferay-portal-6.2-ce-ga6/tomcat-7.0.62/bin/startup.sh (code=exited, status=203/EXEC)
liferay.service: Failed to execute command: Permission denied

@jverweijL
Copy link
Author

Did you set the right user/group?

User=ubuntu
Group=ubuntu

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment