Liferay 7 installation – A step by step guide

Liferay 7 installation is all you need to know before you start working with it.

Before start working with Liferay, you need to understand how to do Liferay 7 installation. Though starting from version 7, Liferay introduced the OSGi framework, the installation and setup are similar to its earlier release. This article will explore all necessary and basic steps to perform the Liferay 7 installation in your local environment.

At the time of writing this, Liferay 7 is the latest version released. It is full of new features. It is more powerful than ever before. You can refer to my blog on Liferay 7 (DXP) introduction. Just like all earlier releases, Liferay 7 comes in two flavors.

  • Community Edition (CE)
  • Enterprise Edition (EE)

EE version is now called Digital Experience Portal or DXP in short. Needless to say that, the CE version is still fully opensource and available freely.

The beauty of Liferay 7 lies in the OSGi container, which facilitates modular development. The clear difference you will experience is the brand new and fresh look of Liferay 7 compare to all previous releases. Let us learn how to perform the Liferay 7 installation.

Install Java 8

The first step in Liferay 7 installation is to install Java. Since Liferay 7 is compatible with Java 8 (and higher version) only, you need to install Java 8 first. Liferay took this decision to use all the latest features of Java. Also, Oracle has announced to stop any further support for Java 7.

You can refer article on How to install Java on a Windows machine and make Java 8 ready before any further action. In that article, please choose Java 8 while downloading it from the oracle site.

Liferay 7 Installation

After installing Java 8, you are ready for the Liferay 7 installation. At the time of writing this, 7.1 is the latest version released by Liferay. You can download Liferay 7.1 from the below links.

Please note that the CE version is completely free while the DXP version has 30 days trial period. Once expired, you must have to supply a valid license file.

Liferay is a portal and comes as a bundle with Tomcat (since long) and Wildfly (recently introduced). Wildfly is a community project from RedHat company. It is another application server. At this moment, Liferay is recommending using the Tomcat bundle in a standalone environment. So in our case, we will use Liferay 7.1 with the tomcat bundle.

Download & Other setups.

Let us first download Liferay 7.1. We will use the CE version. Download it from this link. It is in the form of a ZIP file. Extract it into some folder in your local. Liferay ships with a default database called HSQLDB. It is an embedded (in memory) database, and no setup is required. However, Liferay does not recommend using it in a production environment.

It would always be a great idea to start the Liferay server with MySQL database. You need to instruct Liferay to use MySQL instead of HSQLDB (default) database. For this, just create one file called portal-ext.properties just under the Liferay server’s extracted folder in the previous step.

Add the following content to portal-ext.properties file.

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

 

These are JDBC properties used by Liferay 7 to establish interaction with the MySQL database. You also need to create a schema – liferay71ce in MySQL, which I have mentioned in jdbc.default.url property above.

Note: For Liferay 7, you need to install MySQL 5.7 or above.

Settings for Performance improvement in Local

After this, open \tomcat-9.0.6\bin directory from the folder where you unzip the Liferay 7.

Before starting Liferay, we will do some settings to increase the Liferay’s performance in the local environment. Open setenv.bat file in above folder – tomcat-9.0.6\bin. You will see its content as follows.

if exist "%CATALINA_HOME%/jre1.6.0_20/win" (
    if not "%JAVA_HOME%" == "" (
        set JAVA_HOME=
    )

    set "JRE_HOME=%CATALINA_HOME%/jre1.6.0_20/win"
)

set "CATALINA_OPTS=%CATALINA_OPTS% -Dfile.encoding=UTF8 -Djava.net.preferIPv4Stack=true -Dorg.apache.catalina.loader.WebappClassLoader.ENABLE_CLEAR_REFERENCES=false -Duser.timezone=GMT -Xmx1024m -XX:MaxMetaspaceSize=512m"

We will update the value of the CATALINA_OPTS variable as per be below snippet.

if exist "%CATALINA_HOME%/jre1.6.0_20/win" (
    if not "%JAVA_HOME%" == "" (
        set JAVA_HOME=
    )

    set "JRE_HOME=%CATALINA_HOME%/jre1.6.0_20/win"
)

set "CATALINA_OPTS=%CATALINA_OPTS% -Dfile.encoding=UTF8 -Djava.net.preferIPv4Stack=true -Dorg.apache.catalina.loader.WebappClassLoader.ENABLE_CLEAR_REFERENCES=false -Duser.timezone=GMT -XX:NewRatio=3 -Xms1560m -Xmx3072m -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:+CMSParallelRemarkEnabled -XX:SurvivorRatio=20 -XX:ParallelGCThreads=6 -XX:MaxMetaspaceSize=512m"

I have added a few JVM options to improve the performance and Xms and XmX, which represent initial and max memory, respectively. You can set the value of Xms and Xmx based on your system configuration and available memory.

You can refer to the below links to get more detailed information about performance in Liferay.

Configuration

You are now ready to start Liferay 7.1. Find startup.bat in the same directory and double click on it to start Liferay 7. Since this is the first time, Liferay will create all database tables and sample data, and hence it will take a little longer time.

Second and subsequent times, the Liferay server will take comparatively less time to start. You will see a tomcat console showing all logs during the startup. Once the server is up, you will see the first screen on the browser as below.

Liferay 7 configuration - Liferay 7 installation

If you wish, you can update Portal Name, First Name. Last Name, Email, and Default Language of the portal from Basic Configuration section. The default details are sufficient for local setup, and hence I will keep it as it is. Just click on the Finish Configuration button, and Liferay will complete the last step of doing configuration. This is a one-time task. Liferay will not ask to set these data next time onward.

Once you save the configuration, Liferay will ask to restart the server to make the above changes in effect. Just press Ctrl+C from the tomcat (Liferay) console and allow some time to shut it down. The tomcat window will be disappeared on a successful shutdown. This is the last step in the Liferay 7 installation.

First-time activities

Double click on the startup.bat file again to start the server. Once the server is up and running, you need to log in with the default email address and password. Give the email address test@liferay.com (in the above case) and password as a test.

The default password is test. On successful login, Liferay will ask for Terms of Use, and you have to accept it. On the next screen, Liferay will ask to update the password. After that, the next screen will ask you to set a security question. Congratulations, you have successfully completed Liferay 7 installation.

By default, this user (test@liferay.com) is the super admin of the Liferay portal. Hence it has full access to everything on Liferay 7.

Liferay 7.1 folder structure

Let us get a basic understanding of the folder structure of the Liferay server. You will see the project structure of Liferay as below screenshot.

Liferay 7 folder structure - Liferay 7 installation

 

  • data: Liferay 7 stores various data like document library files (in encrypted format), elastic search index files, and HSQLDB (in memory) database details in this folder.
  • deploy: This is the folder where you can deploy OSGI modules (JARs) files and WARs files.
  • license: This folder contains some copyright information about the product.
  • logs: There is where the logs are generated.
  • osgi: This is the folder where all OSGI specific information is stored. For example, Liferay deploys all OSGI modules in osgi/modules folder while the WARs in osgi/war folder. The folder osgi/marketplace stores lpkg files containing the executable out of the box Liferay modules. In contrast, in all previous Liferay releases (till 6.2), the Liferay executable code was stored inside the tomcat’s ROOT folder.
  • tomcat-9.0.6: This is the tomcat folder. Since we are using the tomcat bundle, all tomcat specific files are available inside this folder.
  • tools: This folder contains a few of the tools used for various purposes, like migration from previous releases.
  • work: it is a temporary folder created by the OSGI container.
  • portal-ext.properties: Liferay reads this file on startup. You can override any specific properties in this file. You can also define your own custom properties, which are available across the portal.
  • portal-setup-wizard.properties: This file stores the Basic Configuration information about Liferay.

Finally, you are now ready to use Liferay 7.1 portal. We have seen these steps for Windows. Similarly, for other operating systems, the above steps are more or less like the same. Obviously, it will differ in setting the environment variable and choosing a specific file to start Liferay. For example, in Linux, you need to use .sh files (i.e., startup.sh.)

Recommended For You

About the Author: Nilang

Nilang Patel is a technology evangelist who loves to spread knowledge and helping people in all possible ways. He is an author of two technical books - Java 9 Dependency and Spring 5.0 Projects.

3 Comments to “Liferay 7 installation – A step by step guide”

  1. Have a startup problem, I’m absolutly beginner on Java and Liferay so I dont know how to do.
    The catalina.out log is the following:

    19-Jul-2019 11:42:49.350 INFO [main] org.apache.catalina.startup.Catalina.load Server initialization in [755] milliseconds
    Loading jar:file:/Applications/liferay-ce-portal-7.2.0-ga1/tomcat-9.0.17/webapps/ROOT/WEB-INF/lib/portal-impl.jar!/system.properties
    WARNING: An illegal reflective access operation has occurred
    WARNING: Illegal reflective access by com.liferay.petra.reflect.ReflectionUtil (file:/Applications/liferay-ce-portal-7.2.0-ga1/tomcat-9.0.17/lib/ext/com.liferay.petra.reflect.jar) to method java.lang.Object.clone()
    WARNING: Please consider reporting this to the maintainers of com.liferay.petra.reflect.ReflectionUtil
    WARNING: Use –illegal-access=warn to enable warnings of further illegal reflective access operations
    WARNING: All illegal access operations will be denied in a future release
    19-Jul-2019 11:42:50.755 SEVERE [main] org.apache.catalina.core.StandardContext.listenerStart Error configuring application listener of class [com.liferay.portal.spring.context.PortalContextLoaderListener]
    java.lang.ExceptionInInitializerError
    at com.liferay.petra.reflect.ReflectionUtil.(ReflectionUtil.java:160)
    at com.liferay.portal.spring.context.PortalContextLoaderListener.(PortalContextLoaderListener.java:479)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500)
    at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:481)
    at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:151)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4604)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5150)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:713)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:690)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:695)
    at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:631)
    at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1832)
    at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
    at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:118)
    at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:526)
    at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:425)
    at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1577)
    at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:309)
    at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:123)
    at org.apache.catalina.util.LifecycleBase.setStateInternal(LifecycleBase.java:424)
    at org.apache.catalina.util.LifecycleBase.setState(LifecycleBase.java:367)
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:929)
    at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:831)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1377)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1367)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
    at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:140)
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:902)
    at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
    at org.apache.catalina.core.StandardService.startInternal(StandardService.java:423)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
    at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:928)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:634)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:567)
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:350)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:492)
    Caused by: java.lang.NoSuchFieldException: modifiers
    at java.base/java.lang.Class.getDeclaredField(Class.java:2417)
    at com.liferay.petra.reflect.ReflectionUtil.(ReflectionUtil.java:155)
    … 48 more

    19-Jul-2019 11:42:50.757 SEVERE [main] org.apache.catalina.core.StandardContext.listenerStart Skipped installing application listeners due to previous error(s)
    19-Jul-2019 11:42:50.758 SEVERE [main] org.apache.catalina.core.StandardContext.startInternal One or more listeners failed to start. Full details will be found in the appropriate container log file
    19-Jul-2019 11:42:50.766 SEVERE [main] org.apache.catalina.core.StandardContext.startInternal Context [] startup failed due to previous errors
    19-Jul-2019 11:42:50.932 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in [1,576] milliseconds

    It’s clear to me I have a warning of “illegal reflective access operation” but I think the problem (Liferay portal don’t start) is the error on the listener at com.liferay.petra.reflect.ReflectionUtil but I haven’t found nothing to help me to solve that!

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.