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.
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.
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.
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 [email protected] (in the above case) and password as a test.
By default, this user ([email protected]) 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.
- 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.)