Recent Bloggers

Jan Verweij

2 Publications
23 octobre 2017

Yasuyuki Takeo

2 Publications
18 octobre 2017

David H Nebinger

63 Publications
14 octobre 2017

Anderson Perrelli

1 Publications
9 octobre 2017

Kyle Joseph Stiemann

11 Publications
6 octobre 2017

Petteri Karttunen

2 Publications
5 octobre 2017

James Hinkey

8 Publications
5 octobre 2017

Sushil Patidar

10 Publications
4 octobre 2017

Bryan Cheung

37 Publications
4 octobre 2017

Olaf Kock

120 Publications
3 octobre 2017

Hosting Liferay 7/DXP on AWS Lightsail

General Blogs 31 juillet 2017 Par Ahamed Hasan


Amazon Lightsail is the easiest way to get started with AWS for developers who just need virtual private servers. Lightsail includes everything you need to launch your project quickly – a virtual machine, SSD-based storage, data transfer, DNS management, and a static IP – for a low, predictable price.This is one of the latest offerings from Amazon Web Services. With the help of Lightsail, you can avoid all the low level plumbing of hosting an EC2 instance but rather spin off your instances at real rapid speed. To know more about this service you can have a look at this blog.

In this blog, i am going to give you the most simplistic steps required to launch Liferay 7/DXP on Amazon. Many of us would have done a similar hosting with Amazon EC2 but this hosting is even simpler. The objective of this blog is to document those steps so that any one that wants Liferay 7/DXP production instance up and running in the least possible time can make use of the steps.


Creating your Lightsail Instance:

All you need to get your first instance with Lightsail is an AWS account. If you do not have an account already, create one by visiting Once you have successfully created your AWS account, login to the AWS Management Console. From the Management Console, click Lightsail under "Compute" category.

This will open a new window with the Lightsail dashboard. This dashboard is the one-stop shop to create, manage and monitor your Lightsail instances. You can click on the "Create Instance" button to get started with your first instance. For hosting Liferay you need at least an instance with atleast 2GB RAB of any Operating System of your choice. My OS preference is usually Ubuntu 16.04 LTS.

In less than a minute you will see your Virtual Machine up and running. It would have assigned an IP address by default and also keep some ports opened to access the instance from outside the world. Right from this dashboard, you can also invoke the server console by clicking the button "Connect Using SSH". But for matured systems administrators this might not be the right approach.

Connecting to the Instance:

Seasoned server administrators would usually prefer connecting to this newly created instance from a conventional command prompt (non-windows) or from putty client (windows). For both these approaches you need the private key. Download the private key from the "Account" page. There will be one Default private key. It will get downloaded as a ".pem" file. Once it is downloaded keep it in a secure location and also change the permission to this file by tying the command,

>chmod 400 sample.pem

Rename "sample.pem" to the actual file name that you have downloaded. After changing the permissions you can remotely connect to your instance with the command,

>ssh -i sample.pem ubuntu@IP-ADDRESS

Replace the IP-ADDRESS with the actual public IP address of this instance provided by Lightsail. For the first time while connecting through SSH it will ask you to allow the access and you should type in "yes". In case of windows, you will have to upload the PPK file in the putty client. There are tools available to convert your ".pem" file to ".ppk" file. You can do this with the help of a tool called PuttyGen. Once you have successfully connected to your instance through SSH you should see the following screen.


Preparing the Ground:

Now that you have successfully connected to your Lightsail instance, you have to do the following eight things as a "root" user. In order to switch the user as root, give the command,

>sudo su

1) Update & Upgrade the OS

The first thing is to get the patches and update the operating system. Run the command,

>apt-get update

Once the packagas are updated, now run the command to upgrade the OS with the latest set of packages

>apt-get upgrade

After you have performed an upgrade, it might ask you to restart the system. You can do this either from the Lightsail console by clicking the "restart" menu item or issuing the command "init 6" from the command prompt.


2) Changing TimeZone

Based the country and locale that you want to host your Liferay 7/DXP change the TimeZone. On a Linux system, this can be done by the command,

>dpkg-reconfigure tzdata

You can set the timezone in the resulting screens.


3) Install Apache2 WebServer

Apache is the most commonly used Web server on Linux systems. Web servers are used to serve Web pages requested by client computers. All the requests to Liferay will be routed through Apache. For installing Apache2, use this command,

>apt-get -y install apache2

Apache Webserver listens on port 80 which is opened by default on your Lightsail instance. To test apache is successfully intalled. Open a web browser and type the IP-ADDRESS of your VM.  You should get this page.


4) Enable Apache Module "proxy_ajp"

The next step is to connect Apache2 with the Tomcat (Liferay). We are going to establish this connection with the help of an Apache module called "proxy_ajp". First you need to enable the module by issuing the command,

>a2enmod proxy_ajp

Once it is enabled successfully, you have to create a file named "proxy_ajp.conf" under "/etc/apache2/conf-enabled" folder and put these two lines,

ProxyPass / ajp://localhost:8009/
ProxyPassReverse / ajp://localhost:8009/

Save and close the file. Restart Apache by running,

>service apache2 restart

To confirm that the proxy_ajp module is enabled and configured properly, open the brower and type the IP-ADDRESS. You should get the following message.

Service Unavailable

The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later.

Apache/2.4.18 (Ubuntu) Server at Port 80

The proxy_ajp module is trying to invoke the Tomcat (Liferay) server on the back. But the Tomcat (Liferay) is still not installed, this message is justified for the time being.


5) Install MySQL Database

The next step is to install and configure MySQL Database to hold all Liferay tables. This can be done with the command,

>apt-get -y install mysql-server

During the installation of MySQL you will be prompted to set the password for the mysql user "root". Give the password of your choice. After the successful installation of MySQL, get inside the MySQL prompt,

>mysql -u root -pPASSWORD

When you are inside the MySQL prompt, create an empty database,

mysql> create database lportal character set utf8;

Confirm that the database is created nicely. You can "exit" from the prompt back to the shell.


6) Install Java Runtime Environment

Liferay is purely based on Java and all it needs to run is a JRE. Lets install the default JRE that comes with Ubuntu Operating System with the command,

>apt-get -y install default-jre

Lets confirm that the JRE is installed properly by issuing the command,

>java -version

 It should display the below result,

openjdk version "1.8.0_131"
OpenJDK Runtime Environment (build 1.8.0_131-8u131-b11-2ubuntu1.16.04.3-b11)
OpenJDK 64-Bit Server VM (build 25.131-b11, mixed mode)

Great, you are done with the installation of JRE.


7) Install MailUtils

We need the ability for Liferay to fire emails from the portal. For this we need to setup the SMTP server. This can be done with the command,

>apt-get -y install mailutils

At the time of installation of the postfix mail server, it will ask you to select the type. Go with the option "Internet Site". Confirm that the email server is configured properly, by sending a test mail from the command line,

>echo "My message" | mail -s "subject"


8) Install Unzip Utility

This is the last and final step. As we have to unzip the Liferay Tomcat bundle we need an unzip utility. Install it with the command,

>apt-get -y install unzip

Congratulations, you are done with all the seven steps inorder to prepare the ground. Now, it is time to install Liferay 7/DXP. Till now we have done everything as a "root" user. Exit as a "root" and switch to the "ubuntu" user.


Install Liferay 7/DXP:

This is the final thing towards getting our Liferay Portal up and running. From the home folder "/home/ubuntu" download the latest version of Liferay Tomcat bundle. You can get the link of this file by going to Based on your current location you may download this file from a different mirror.


After the download of this bundle, unzip it with the command,


The whole bundle gets unzipped in the folder "liferay-ce-portal-7.0-ga4" which will be the LIFERAY_HOME. "cd" into this folder and then to "tomcat-8.0.32/bin/" for starting the tomcat server. Before starting the server you have to do one small thing. Open the file "" inside this folder and remove the last parameter "-XX:MaxPermSize=384m" as it is no longer required in Java 8. Now start the server by invoking "./".

You can view the console by typing "tail -f ../logs/catalina.out". Once the server is completely started, you can open the open the browser and hit the IP-ADDRESS. You should get the Basic Configuration page of Liferay.

The last step is to complete the basic configuration. You can uncheck the option for not adding the sample data. Also point do the database configuration by pointing to the MySQL database that we have created earlier. Click "Finish Configuration". Post this you may have to restart the server again for the changes to take effect. After the second restart when you open the browser and hit the IP-ADDRESS you will land in the default landing page of Liferay 7/DXP. 

Congratulations!! You have successfully setup Liferay 7/DXP on Amazon Lightsail Cloud. Enjoy playing around with the great features of Liferay 7/DXP. You just have to point your custom domain to this IP-ADDRESS in order for your website to be live in the production environment

Ahamed Hasan
Liferay Architect, Trainer & Consultant
Bangalore, India

AlloyUI Custom Validation in DXP

Technical Blogs 20 juillet 2017 Par Ahamed Hasan

AUI Input Field Custom Validation

Offlate, i have been working on some serious devolopment using Liferay 7 DXP. Having delivered close to half a dozen corporate training programs on Liferay 7 DXP it is time for me to get my hands wet on implementing some of the cool features of Liferay the DXP way. I thought it is a good idea to share my tricks and tips through these blogs so that it can he of help to someone that would like to implement similar stuff in their Liferay 7 implementations.


In one of the projects that i am involved, we are developing a very simple custom user registration portlet. The registration form will take only three fields - Email Address, First Name and Last Name. On the other side we have Implemented an MVCActionCommand to create an user using API's of UserLocalServiceUtil. One of the requirements is to do a front-end validation to check if an user with the same email address already exists. If so, the form should not get subitted at all.

Here is the snapshot of the Create Account Portlet with the error message shown.


Frontend Code:

Here is the code that we wrote on the view.jsp of this portlet. See, in this code, how a porltet resource request is invoked programmatically inside the custom <aui:validator> block. One good thing about Liferay 7 DXP is the jQuery libraries are included by default unlike the earlier versions of Liferay.



We have implemented an OSGI component corresponding to the Resource Request and mapped with the particular resourceId.



This way of invoking a portlet URL through Javascript is really powerful and the same has been invoked from the AUI validator script. Feel free to make use of this code in your projects. In case of any feedback or suggestions feel free to get in touch with me.

Thank you for reading this blog!!

Ahamed Hasan

Affichage de 2 résultat(s).