How to Install Liferay CMS on Debian 9

 

Liferay is a free and open source content management software written in Java and uses MySQL to store their data. Liferay is a web based application portal that can be used to build websites and portals as an assembly of themes, pages, and a common navigation. Liferay comes with simple and easy to use programming interface that allows users with no programming skills for the basic website installation and administration. Liferay supports for the variety of extensions and plug-ins for many programming languages.

In this tutorial, we will show you how to install Liferay on Debian 9 server.

Requirements

  • A server running Debian 9.
  • A non-root user with sudo privileges.

Update the System

Before starting, update the system with the latest version. You can do this with the following command:

sudo apt-get update -y
sudo apt-get upgrade -y

Once your system is up-to-date, restart the system to apply all the updates.

Install Java

Xwiki is a Java based application, so you will need to install Java 8 first. By default Java 8 is not available in the Debian 9 repository. You can install Java 8 by adding the webupd8team PPA repository to your system.

First, add the PPA by running the following command:

sudo add-apt-repository ppa:webupd8team/java

Next, update the repository with the following command:

sudo apt-get update -y

Once the repository is up to date, you can install Java 8 by running the following command:

sudo apt-get install oracle-java8-installer -y

After installing Java, you can check the version of Java with the following command:

java -version

You should see the following output:

java version "1.8.0_161"
Java(TM) SE Runtime Environment (build 1.8.0_161-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.161-b12, mixed mode)

Install MariaDB

By default, the latest version of the MariaDB is not available in Debian 9 default repository. So you will need to add the MariaDB repository to your system. You can add the repository by running the following command:

sudo apt-get install software-properties-common -y
sudo apt-key adv –recv-keys –keyserver keyserver.ubuntu.com 0xF1656F24C74CD1D8
sudo add-apt-repository ‘deb [arch=amd64] http://www.ftp.saix.net/DB/mariadb/repo/10.1/debian stretch main’

Next, update the repository by running the following command:

sudo apt-get update -y

Finally, install the MariaDB server with the following command:

sudo apt-get install mariadb-server -y

By default, MariaDB installation is not secured. So you will need to secure it first. You can do this by running the mysql_secure_installation script.

sudo mysql_secure_installation

Answer all the questions as shown below:

   
Enter current password for root (enter for none): Enter
Set root password? [Y/n]: Y
New password: 
Re-enter new password: 
Remove anonymous users? [Y/n]: Y
Disallow root login remotely? [Y/n]: Y
Remove test database and access to it? [Y/n]: Y
Reload privilege tables now? [Y/n]: Y

The above script will set the root password, remove test database, remove anonymous user and Disallow root login from a remote location.

Once the MariaDB installation is secured, start the MariaDB service and enable it to start on boot time by running the following command:

sudo systemctl start mysql
sudo systemctl enable mysql

Next, you will need to create a database and user for liferay. First, log in to MariaDB shell using the following command:

mysql -u root -p

Enter your root password, then create a database for liferay with the following command:

MariaDB [(none)]>CREATE DATABASE lportal;

Next, create a username and password for liferay with the following command:

MariaDB [(none)]>CREATE USER ‘lportal’@’localhost’ IDENTIFIED BY ‘password’;

Next, grant privileges to the lportal database with the following command:

MariaDB [(none)]>GRANT ALL PRIVILEGES ON lportal.* TO ‘lportal’@’localhost’;

Next, flush the privileges with the following command:

MariaDB [(none)]>flush privileges;

Finally close the MySQL console:

MariaDB [(none)]>exit;

Download and Install Liferay

First, you will need to download the latest version of the Liferay application bundled with Apache Tomcat. You can download it with the following command:

wget https://excellmedia.dl.sourceforge.net/project/lportal/Liferay%20Portal/7.0.4%20GA5/liferay-ce-portal-tomcat-7.0-ga5-20171018150113838.zip

Once the download is completed, extract the downloaded file with the following command:

unzip liferay-ce-portal-tomcat-7.0-ga5-20171018150113838.zip

Next, copy the extracted directory to the /var/ directory:

sudo cp -r liferay-ce-portal-7.0-ga5 /var/liferay

Next, you will need to create a new portal-ext.properties file and add MySQL details. You can do this using the following command:

sudo nano /var/liferay/tomcat-8.0.32/webapps/ROOT/WEB-INF/classes/portal-ext.properties

Add the following lines:

jdbc.default.url=jdbc:mysql://localhost/lportal?useUnicode=true&characterEncoding=UTF-8&useFastDateParsing=false
jdbc.default.driverClassName=com.mysql.jdbc.Driver
jdbc.default.username=lportal
jdbc.default.password=password

Save and close the file, when you are finished.

Now, start the Liferay Portal installation by running the following script:

sudo bash /var/liferay/tomcat-8.0.32/bin/startup.sh

Wait some time for application to be fully started. You can see the application log using the following command:

tail -f /var/liferay/tomcat-8.0.32/logs/catalina.out

Once the application is fully started, open your web browser and type the URL http://your-server-ip:8080, you will be redirected to the Liferay Application Portal.

Congratulations! you have successfully installed Liferay Portal on your Debian 9 server.

Source