Liferay + Tomcat

Install Java

For this installation we will use Java 11 OpenJDK.

Install JDK from     or on Centos terminal execute

sudo yum install java-11-openjdk-devel

Check your version by typing

 java --version

If you have multiple Java versions installed on the server you can change the default version using the alternatives system utility:

sudo alternatives --config java

[[email protected] ~]# sudo alternatives --config java There are 2 programs which provide 'java'.   
Selection Command -----------------------------------------------
1 java-11-openjdk.x86_64 (/usr/lib/jvm/java-11-openjdk-
*+ 2 java-11-openjdk.x86_64 (/usr/lib/jvm/java-11-openjdk-

At the time of writing last Tomcat version was 9.0.16 at


Tomcat setup

Create group tomcat:

[[email protected] ~]# sudo groupadd tomcat

Create user tomcat and add it to group tomcat :

[[email protected] ~]#  sudo useradd -M -s /bin/nologin -g tomcat -d /opt/tomcat tomcat 

This will also disable anyone from logging in as tomcat user.

Create the directory where tomcat will be installed and unpack the archive :

[[email protected] ~]# mkdir /opt/tomcat
[[email protected] architech]# sudo tar xvf apache-tomcat-9*tar.gz -C /opt/tomcat --strip-components=1

Change the ownership of the tomcat files

#  cd /opt/tomcat 
# sudo chgrp -R tomcat /opt/tomcat

Next, give the tomcat group read access to the conf directory and all of its contents, and execute access to the directory itself:

# sudo chmod -R g+r conf 
# sudo chmod g+x conf

Then make the tomcat user the owner of the webapps, work, temp, and logs directories:

 sudo chown -R tomcat webapps/ work/ temp/ logs/

Install systemd unit file

To be able to run Tomcat as a service we will create systemd unit file 

#nano /etc/systemd/system/tomcat.service

Contest of this file is as follows :

# Systemd unit file for tomcat
Description=Apache Tomcat Web Application Container


Environment='CATALINA_OPTS=-Xms512M -Xmx1024M -server -XX:+UseParallelGC'

ExecStop=/bin/kill -15 $MAINPID



Now we need to reload daemon and start the service

# sudo systemctl daemon-reload

To start and check status of Tomcat run :

# sudo systemctl start tomcat
# sudo systemctl status tomcat

Enable Tomcat service by running :

sudo systemctl enable tomcat


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.