Total Pageviews

Tuesday, July 23, 2013

A Note of Liferay Portal Instances

Liferay provides us facility to run more than one portal instance on a single server. Liferay comes with one inbuilt portal instance, which is names 'Liferay' and its web id is '', however it can be modified with following properties in file:
Note: There are several other properties regarding portal instances present in as well which can be referred in Liferay Portal SRC.

If we login as administrator (generally, and go to control panel we can see list of all available portal instances in 'Portal Instances' section inside 'Server' category. Here we will see a table with atlest one entry (inbuilt one) , lets know what the column of this table depicts:

  • Instance ID: It’s a numeric Id, generated by code automatically at the time of Instance creation. Internally this Instance ID is referred as 'companyid' in the database table. We can see all available instances in database table 'company'.
  • Web ID: It’s a user-generated ID for the instance. It can be anything relevant but a general convention is to use the domain name.
  • Virtual Host: Domain name which is to be configured in the network kept here. This domain name is referred when users are directed to our Liferay server, and the same enables Liferay to resolve request for proper portal instance.
  • Mail Domain: The domain name to be used as mail host for this instance kept here. Liferay will use this to send email notifications from the portal, and the same is used for creating the default test user, as
  • # of Users: Depicts current number of users on particular portal instance.
  • Max # of Users: Depicts total number of users allowed on particular portal instance.
  • Active: Depicts if the portal instance active or not (Yes / No).

Enough of theory, lets experience it. Startup the server and replicate the following steps:
  1. Login as administrator. ( will work)
  2. Navigate to Manage → Control Panel → Portal Instances section in 'Server' category.
  3. By default only one portal instance will be listed. To add new, click on add button fill up the form fields. Say you have created ''.
  4. Assuming that you are working on your local system, you have to edit the host file (%SYSTEMROOT%\ System32\ drivers\ etc\ hosts). Add the following in the file:
    If you are in network then you can map the entry with the IP address of the server on which Liferay is running and try.
  5. Start the browser (restart in case already running) and put '<PORT>' in address bar. What you see now in the new portal instance.
  6. You can login as test@<domainname>, ( in out case). This is the admin user of the instance. As an administrator you cannot see the 'Server' category in Control Panel, which means new instance can be created only from main portal instance.
If we dig in further, we will come to know that we can have different properties file for each portal instances. To enable this feature, set the "company-id-properties" system property to true. The read order will now be:, then, and then Note that not all properties can have different values per company. This functionality is only available for legacy reasons. The preferred way to configure a portal instance is through the Control Panel.

Handling Portal Instances in Custom Code:
In real life scenario, we may need to process data differently for each Portal Instance in our custom code. So have a look on small code snippet:
Hope you enjoyed the reading.


  1. Hi apoorva, thanks for a nice article on liferay posrtal instances.

    I have a question regarding it. So is there any way that with our default user "" we ca login to all the portal instances that we create from default portal OR is there any way that we can manage some OMNI-ADMIN user for different instances.

  2. Thanks for that "Instance ID" paragraph. I was trying to figure out where to get the instance id. Could not find it anywhere, and did not wanna do a db dump. Thanks! :)