Installing Liferay on Mulesoft Tcat
For this section, we will refer to your Tcat server’s installation location as
[TCAT_HOME]. If you don’t already have an existing Tcat server, we recommend you download a Liferay/Tcat bundle from http://www.liferay.com/downloads/liferay-portal/available-releases. If you have an existing Tcat server on which you’d like to deploy Liferay manually, please follow the steps below.
Your first step is to download the latest Liferay
.war file and Liferay Portal dependencies from http://www.liferay.com/downloads/liferay-portal/additional-files. The Liferay
.war file should be called
liferay-portal-6.2.x-[date].war and the dependencies file should be called
Next, let’s get started by addressing Liferay’s library dependencies.
To run Liferay Portal on your Tcat server, you first need to make some JAR files available on Tcat’s global classpath. These include the Liferay Dependency JARs, a JDBC driver for your database, and some other dependencies that Liferay Portal requires.
Create the folder
Extract the Liferay dependencies file and copy the
Next, you need a few
.jar files that are included as part of the Liferay Tcat bundle, but are not included with Tcat. You’ll have to download them yourself, so let’s get started. Place these
.jar files into
Although you can get each
.jar listed above separately, it may be more convenient to get them by downloading the Liferay source code and copying them from there. Once you have downloaded the Liferay source, unzip the source into a temporary folder. You can find the
.jar files in
- Make sure the JDBC driver for your database is accessible by Tomcat. Obtain the JDBC driver for your version of the database server. In the case of MySQL, use
mysql-connector-java-[version]-bin.jar. You can download the latest MySQL JDBC driver from http://dev.mysql.com/downloads/connector/j/. Extract the JAR file and copy it to
Now that you have the necessary libraries in place, we’ll move on to configuring your domain.
If you’re installing Liferay Portal onto an existing Tcat server, you should be familiar with the Tcat Administration Console. The following instructions assume you have a Tcat server with the Administration Console and a separate, managed Tcat server instance where you’ll deploy Liferay. To find information specific to Tcat server installation and management, see Mulesoft’s Tcat Documentation. You have to do a few things to configure your managed Tcat server instance:
Set environment variables
Create a context for your web application
Modify the list of classes/JARs to be loaded
Specify URI encoding
Figure 15.2: You can log in to the Tcat Administration Console to manage your Tcat servers.
Next, you’ll configure your managed Tcat instance.
To set the
CATALINA_OPTS environment variable, you need to add a server profile. In the Tcat Administration Console, navigate to the Administration tab and click Server Profiles. Name the profile appropriately (Liferay 6.2, perhaps), provide a description if you wish, select the workspace where you’ll keep your profile (
/Profiles is a logical choice), and click the Add Variable button. Name it
CATALINA_OPTS and give it the following value:
-Dfile.encoding=UTF8 -Dorg.apache.catalina.loader.WebappClassLoader.ENABLE_CLEAR_REFERENCES=false -Duser.timezone=GMT -Xmx1024m -XX:MaxPermSize=256m"
This sets the character encoding to UTF-8, sets the time zone to Greenwich Mean Time and allocates memory to the Java virtual machine.
Apply the profile to the Tcat server where you’re deploying Liferay. To do so, go to the Servers tab, select the desired server, and select your profile from the Set Profile dropdown menu.
Create a file locally called
Click your server’s name to edit its configuration. Using the Files tab, navigate to the directory
[TCAT_HOME]/conf/Catalina/localhost and upload your ROOT.xml file. Setting
crossContext="true" allows multiple web apps to use the same class loader. In the content above you will also find commented instructions and tags for configuring a JAAS realm, disabling persistent sessions and disabling sessions in general.
Still in your server’s Files tab, open
[TCAT_HOME]/conf/catalina.properties, click the Edit catalina.properties link, and replace the line:
This allows Catalina to access the dependency jars you extracted to
To ensure consistent use of UTF-8 URI Encoding, edit
[TCAT_HOME]/conf/server.xml and add the attribute
URIEncoding="UTF-8" where you see
redirectPort=8443, in the definition of your connectors (HTTP and AJP). For example:
Figure 15.3: You can edit your Tcat configuration files in the Administration Console.
Excellent work! Now it’s time to configure your database.
If you want Tcat to manage your data source, use the following procedure. If you want to use Liferay’s built-in data source, you can skip this section.
Make sure your database server is installed and working. If it’s installed on a different machine, make sure it’s accessible from your Liferay machine.
Using the Tcat Administration Console, add your data source as a resource in the context of your web application specified in
Note the above resource definition assumes your database name is lportal and your MySQL username and password are both root. You’ll have to update these values with your own database name and credentials.
Your Tcat managed data source is now configured. Let’s move on to your mail session.
If you want to manage your mail session within Tomcat, use the following instructions. If you want to use the built-in Liferay mail session, you can skip this section.
Create a mail session bound to
mail/MailSession. In the Tcat Administration Console, edit
[TCAT_ HOME]/conf/Catalina/localhost/ROOT.xml and configure a mail session. Be sure to replace the mail session values with your own.
Super! Your mail session is configured. Next, you need to connect Liferay to the mail session and database connections you just created.
Configuring your Database and Mail Session
In this section you’ll specify appropriate properties for Liferay to use in connecting to your database and mail session.
If you are using Tcat to manage your data source, add the following line to the
portal-ext.properties file in your Liferay Home. This points Liferay Portal to your data source:
Otherwise, if you are using Liferay Portal to manage your data source, follow the instructions in the Deploy Liferay section for using the setup wizard.
- If you want to use Liferay Portal to manage your mail session, you can configure the mail session in Liferay Portal. After starting your portal as described in the Deploy Liferay section, go to Control Panel → Server Administration → Mail and enter the settings for your mail session.
If you are using Tcat to manage your mail session, add the following to your
portal-ext.properties file to reference that mail session:
Before you deploy Liferay Portal, let’s look at configuring Portal Access Control Lists (PACL) with Liferay on Tomcat.
To enable PACL, you need to enable the security manager and add some required permissions to the server policy configuration file. This entails editing the
CATALINA_OPTS variable and editing the
In the Administration tab of the Tcat Administration Console, click Server Profiles and click the profile applied to your Liferay Tcat server. Click the Value field of the
CATALINA_OPTS variable created earlier, and add the following parameter to it:
The double equals sign tells the app server to use this policy file on top of any existing security policies.
$TCAT_HOME/conf/catalina.policy and add the required permissions:
Now you have PACL enabled and configured for your portal. Let’s deploy Liferay!
It’s time to deploy Liferay as an exploded web archive in your
$TCAT_HOME/webapps folder. The first step is to make sure your Tcat server is running; then follow these steps to deploy and start Liferay.
If you are manually installing Liferay on a clean Tcat server, delete the contents of the
[TCAT_HOME]/webapps/ROOT directory. This removes the default home page.
In the Tcat Administration Console, click the Deployments tab and select New Deployment. Select the server where you’re deploying Liferay and click Upload New Webapp. Browse to the
liferay-portal-6.2.x-[date].war file you downloaded. Make sure you select Advanced Options while uploading Liferay, and under the Name field, type
/ to put the extracted Liferay into
- Once you’ve entered all the deployment details, you can select Deploy. Once you see a Successful message in the Tcat Administration Console, you’re ready to launch Liferay Portal on Tcat!
Now you can navigate to Liferay and follow the setup wizard. Congratulations on successfully installing and deploying Liferay on Mule Tcat!