Liferay in the Cloud

By Stijn Haus

Why Liferay in the cloud?

Today, everybody want things to be done in the cloud. Running your applications in the cloud relieves you from having to manage and scale the hardware. Management of databases, application servers, continuous integration etc is done by the provider and lets you focus on your core business. One thing you don’t find so easily, is how to get a Liferay portal up and running in the cloud. Liferay itself doesn’t offer a cloud service, so we’ll have to construct our own, using the existing providers. It is of course possible to spawn a machine with an IaaS provider and install everything from scratch to get Liferay in cloud – but our goal is here to utilize a PaaS platform to deploy Liferay and make it easier for you.

For this tutorial, I have used Cloudbees. There are 2 ways to get started: the ‘regular’ way, and the quick way which is made possible by the recent addition of  ‘ClickStarts’. The latter is obviously the easiest, but it’s good to see where we come from. It helps in understanding the underlying process.

Before we get started

Before we start, we should install the Cloudbees SDK. You can find it here. Dowload the zip-file, and extract it. Once that’s done, set the BEES_HOME environment variable, and point to the folder in which you unzipped the SDK. Add BEES_HOME to your PATH environment variable. You can check your installation by opening a command window and type ‘bees help’. The first time, Cloudbees SDK will attempt to download a configuration file from its servers. If none is found, it will ask your Cloudbees login and password to create one. Once that’s done, the necessary plugins are downloaded, and you’re good to go.

Note: if you’re behind a proxy, you can edit the bees.bat/ file and change the JAVA_OPTS:

JAVA_OPTS=-Dbees.home=%BEES_HOME% -Dhttp.proxyHost=<your proxy host> -Dhttp.proxyPort=<your proxy port> -Xmx256m

The ‘regular’ way

Follow these easy steps to setup Liferay in the cloud, using the Cloudbees platform. Of course, you’ll need to sign up for an account.

– Create Database (LiferayTryout)
– Download Liferay Tomcat bundle
– Unzip it
– Download Unbundled Liferay
– Copy all files from the Bundled version’s tomcat-7.0.27/lib/ext folder into the unbundled WAR’s WEB-INF/lib folder (14 items, although ccpp.jar is double and can be skipped). In windows, you can use 7Zip to browse the war-file, and drag and drop the jar files into the right folder
– Create a file in the unbundled WAR’s WEB-INF/classes folder (again, you can create it outside the war, and drag and drop it in afterwards)
– Update, to have following properties:

jdbc.default.driverClassName= com.mysql.jdbc.Driver
jdbc.default.url=jdbc:mysql://yourDatabaseServer:3306/liferay-username?useUnicode=true&characterEncoding=UTF-8& useFastDateParsing=false

– You can find your database server in the “Manage” tab of your Cloudbees database
– Create App (JVM Web Application WAR)
– Liferay requires quite a lot of memory. The free edition of Cloudbees comes with 128MB, which is probably not enough. You’ll have to switch to the paid (medium or large) edition
– Upload the new WAR file using the Cloudbees SDK. This will take a while, since it’s pretty big. Subsequent deploys will be faster, as the SDK uses a delta system to only deploy the changes. To deploy, use this command:

       bees app:deploy liferay-portal-6.1.1-ce-ga2.war jvmPermSize=256

– Notice we have set the jvmPermSize parameter.
– The SDK will now ask you which application you want to deploy. Enter the name, and watch it progress.
– Your liferay instance is now up and running in the cloud!

The quick way, using Liferay ClickStart

Clickstarts are project templates, a bit like Maven archetypes, if you’ve worked with them. There is a Liferay Clickstart template, which ben be found here:

To use this Clickstart, and have our own Liferay in the cloud, follow these steps:

– Click the button “Deploy instantly on Cloudbees”
– Choose name
– Source repository (GIT) is initialized, Jenkins is configured to automatically build the code, a web application is created, DB created and configured
– Be patient, this can take a while…
– Again, you will have to increase your application memory to 512MB or 1024MB
– Now, use the Cloudbees SDK to locally create the app

       bees create <your-applicationname>

– Go into the created folder
– Change the source code if you want, or immediately upload the application again

       bees deploy -a <your-username>/<your-applicationname>

– Your application is now up and running!


As you can see, the ClickStart way is a lot quicker. On top of that, you also have the immediate creation of a source repository (GIT, in this case) and a Jenkins configuration. While the first method requires a lot of effort and some insight, the second one is quick and easy. We demonstrated use of ClickStarts and in process also deployed Liferay to cloud.
Get the latest in Front-end, once a week, for free.