How to install Liferay Portal Portal CE 7.2 on Centos 8
Enterprise Information Portals or (EIP) have progressive growth from trend to essential business tools. Liferay is one of those tools that is web-based and coded with Java. Liferay Portal Community Edition is based on Digital Experience Plateforme DXP. In this tutorial, we will install Liferay Portal 7.2 on Centos 8 with MariaDB, Tomcat, and Elasticsearch.
Requirements:
- Liferay Portal CE 7.2.0 GA1
- MariaDB 10.3
- Tomcat 9.0 Bundled
- Elasticsearch 6.8.4
- OpenJDK 8
- Centos 8
Hardware: Liferay Portal EE Reference Architecture & Hardware Requirements
Application Server:
- Hostname: APPSRV
- Contents: Liferay Portal 7.2 + MariaDB
Making ready some stuff for APPSRV:
disabling SELinux:
sudo vi /etc/selinux/config
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=enforcing
# SELINUXTYPE= can take one of these three values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
On the option SELINUX Change "enforcing" to "disabled", it takes effect after restarting the machine.
Checking the SELINUX option:
getenforcing
2 Change the name of the server:
sudo hostnamectl set-hostname APPSRV
Checking:
hostnamectl
Restarting ...
3 Adding an exception on the firewall for the port 8080:
Checking status:
sudo firewall-cmd --state
Output:
sudo firewall-cmd --permanent --add-port=8080/tcp
sudo firewall-cmd --reload
Checking the result:
sudo firewall-cmd --list-all
Output:
2- Installation of Liferay Portal and MariaDB on APPSRV:
2-1 Database MariaDB:
Liferay Portal 7.2 supports multiple databases we will use MariaDB 10.3
sudo yum install mariadb mariadb-server
Now we should configure our database server:
a. Starting the service:
sudo systemctl start mariadb
b. Enabling the service to start every startup the server
sudo systemctl enable mariadb
c. Finishing with setting the password and configure some features:
sudo mysql_secure_installation
Now we finish configuring our database server we have to create a database named "lportal" and the user with full access:
mysql -u root -p
Please insert the password which was introduced on the "c" step.
MariaBD [(none)]> create database lportal character set utf8mb4 collate utf8mb4_unicode_ci;
MariaBD [(none)]> create user 'lportalusr'@'localhost' identified by 'lportalpsw';
MariaBD [(none)]> grant all privileges on lportal.* to 'lportalusr'@'localhost' with grant option;
Checking the database:
MariaBD [(none)]> show databases;
Output:
2-2 OpenJDK
Liferay is compatible Java 8 or Java 11in this tutorial we will use OpenJDK 8.
sudo yum install -y java-1.8.0-openjdk java-1.8.0-openjdk-devel
Checking java variable: $JAVA_HOME
echo $JAVA_HOME
Output:
The variable is empty, lets export:
export JAVA_HOME=/usr/lib/jvm/java
export JRE_HOME=$JAVA_HOME/jre
export PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin
Checking:
echo $JAVA_HOME
Output:
2.3 Liferay Portal
With MariaDB and Java Installed and configured, we can install Liferay Portal.
I'm used to using Wget to download files so you need to install it if you want to use it:
sudo yum -y install wget
Download Liferay Portal 7.2 CE:
wget https://github.com/liferay/liferay-portal/releases/download/7.2.0-ga1/liferay-ce-portal-tomcat-7.2.0-ga1-20190531153709761.tar.gz
ls
Copy the file to /opt/ folder:
sudo cp liferay-ce-portal-tomcat-7.2.0-ga1-20190531153709761.tar.gz /opt/
Extract the file:
sudo tar xvf liferay-ce-portal-tomcat-7.2.0-ga1-20190531153709761.tar.gz
ls
Rename Liferay folder to "liferay" (case sensitive) and delete the compressed file we don't need it anymore:
sudo mv liferay-portal-7.2.0-ga1 liferay
sudo rm -f liferay-ce-portal-tomcat-7.2.0-ga1-20190531153709761.tar.gz
Creating the configuration file named "portal-ext.properties" for liferay Database in /opt/liferay/tomcat-9.0.17/webapps/ROOT/WEB-INF/classes/
sudo vi /opt/liferay/tomcat-9.0.17/webapps/ROOT/WEB-INF/classes/portal-ext.properties
jdbc.default.driverClassName=org.mariadb.jdbc.Driver
jdbc.default.url=jdbc:mariadb://localhost/lportal?useUnicode=true&characterEncoding=UTF-8&useFastDateParsing=false
jdbc.default.username=lportalusr
jdbc.default.password=lportalpsw
schema.run.enabled=true
schema.run.minimal=true
You have to match the username and password created on the MariaDB installation step for the security reason avoid to use the root account, on those two lines:
jdbc.default.username=lportalusr
jdbc.default.password=lportalpsw
In our case, the database server is installed on the same server with Liferay Portal if you want to separate them (which is recommended for better performance) you have to change jdbc.default.url: replace "localhost" to the IP address of the remote database server.
jdbc.default.url=jdbc:mariadb://192.168.1.1/lportal?useUnicode=true&characterEncoding=UTF-8&useFastDateParsing=false
Running Configuration check /opt/liferay/tomcat-9.0.17/bin/configtest.sh
cd /opt/liferay/tomcat-9.0.17/bin/
sudo chmomd +x *.sh
sudo ./configtest.sh
Output:
No errors.
Now the first startup, on /opt/liferay/tomcat-9.0.17/bin/
make them executable:
sudo chmod +x *.sh
run ./startup.sh file
sudo ./startup.sh
To monitor the startup server and almost everything on your liferay server messages:
sudo tail -f /opt/liferay/tomcat-9.0.17/log/catalina.out
This file is generated once we start the service
This is part of catalina.out file, it too long the first run and then that will be pretty short in the next restarting.
The server is running and up.
this is the first time running Liferay on http://IPSERVER:8080.
Notice the configuration DATABASE is the same on the portal-ext.properties file.
Choose your Portal Name, First Name, and the Last name, the email is your login so be careful what you type it doesn't matter if it exists or not.
After filling the requested fields click on Finish Configuration and Restart your Liferay server.
cd /opt/liferay/tomcat-9.0.17/bin/
sudo ./shutdown.sh
While liferay service is stopped we will configure the Systemd service.
Systemd
Configuration of Systemd Service, by creating a file named "liferay.service" on /etc/systemd/system/
We need a service user so let's name it liferay, note the -m and -d for home directory.
sudo useradd -m -d /home/liferay -c 'Service Account for Liferay Portal' liferay
sudo vi /etc/systemd/system/liferay.service
Content of the file:
[Unit]
Description=Liferay Portal CE
After=network.target
[Service]
Type=forking
User=liferay
Group=liferay
ExecStart=/opt/liferay/tomcat-9.0.17/bin/startup.sh
ExecStop=/opt/liferay/tomcat-9.0.17/bin/shutdown.sh
TimeoutStartSec=600
TimeoutStopSec=200
SuccessExitStatus=143
[Install]
WantedBy=multi-user.target
we need to change some privileges:
sudo chmod 664 /etc/systemd/system/liferay.service
sudo chown -R liferay:liferay /opt/liferay/
sudo systemctl enable liferay
sudo systemctl start liferay
checking the service:
sudo systemctl status liferay
output:
Let's complete the last part of the configuration:
After accepting the agreement you have to set a password with a question reminder.
and this is the home page of Liferay Portal
Conclusion: Our Liferay Portal is fully functional, check the official website for customization.