Wiki

Main | Proposals

Virtual Hosting (ASP)

This article describes how to use Liferay in an Application Service Provider (ASP) environment in which several isolated Liferay Portal's have to be running side by side in the same application server but isolated from each other. Note that some times you won't need this because a single instance of Liferay Portal supports hosting two or more domain names via communities.

Overview #

Liferay was built from the ground up to be used by application service providers. The following is a sample list of portals running off of one portal instance hitting one database and shows the capabilities of Liferay: http://demo.liferay.net, http://my.ccuc.net, http://my.3sixteen.com, http://www.gatewayfriends.org, http://www.jasonandiris.com. Users in each of these portals have no information about the other portals. They are separated by domain and each portal exists in its own space based on the company's id.

Configure OS's Hosts File #

In order for Virtual Hosting to work, you will need to make sure your operating system's hosts file is modified to support the corresponding host names that are to be supported by Liferay. This is the first step for any version of Liferay.

For Windows, modify C:\windows\system32\drivers\etc\hosts and add :

 127.0.0.1 localhost
 127.0.0.1 localhost2

For Linux or Mac OS X, edit /etc/hosts as below:

 127.0.0.1 localhost.localdomain localhost
 127.0.0.1 localhost.localdomain localhost2

Check /etc/host.conf

 order hosts,bind

Check /etc/nsswitch.conf

 hosts: files nisplus nis dns

Configuring pre-4.3 Versions of Liferay #

This documents virtual hosting on Tomcat, but other deployments are documented in Liferay's official documentation. For this example, we will install two virtual hosts on Tomcat's default port 8080 called localhost and localhost2.

Modify server.xml #

Add a Host entry to the (tomcat directory)/conf/server.xml file
 <Host name="localhost2" appBase="webapps"
  unpackWARs="true" autoDeploy="true" 
  xmlValidation="false" xmlNamespaceAware="false" />

New Configuration File #

  1. mkdir <tomcat>/conf/Catalina/localhost2
  2. Copy <tomcat>/conf/Catalina/localhost/ROOT.xml to (tomcat directory)/conf/Catalina/localhost2/ROOT.xml
  3. Modify "Context path" of <tomcat>/conf/Catalina/liferay2/ROOT.xml as below:
 <Context path="" docBase="${catalina.home}/liferay2/ROOT" 
             debug="0" reloadable="true" cookies="true" crossContext="false" 
             privileged="false" >

New Instance #

  1. Create a new folder (tomcat directory)/liferay2/ROOT
  2. Copy all the content of (tomcat directory)/webapp/ROOT to (tomcat directory)/liferay2/ROOT
  3. Edit (tomcat directory)/liferay2/ROOT/WEB-INF/web.xml modify the company_id to liferay2.com
  4. Create a new folder (tomcat directory)/liferay2/tunnel
  5. Copy all the content of (tomcat directory)/webapp/tunnel to /liferay2/tunnel

HSQLDB should run in server mode #

If you were running hsqldb.jar, you changed hsqldb running in server mode:
  1. Modify hsqldb jdbc connection of (tomcat directory)/conf/Catalina/localhost/ROOT.xml and (tomcat directory)/conf/Catalina/liferay2/ROOT.xml as below:url="jdbc:hsqldb:hsql:localhost"
  2. Start hsqldb server before run tomcat. java -cp (tomcat directory)/common/lib/ext/hsql.jar org.hsqldb.Server
  3. Startup your tomcat, access http://localhost:8080 and http://localhost2:8080 to see your result

Configuring 4.3+ Versions of Liferay #

In "Admin Portlet" under the "Instances" tab click the add button.
 [[image:instances01.JPG]]
Fill in the Web ID, Virtual Host, and Mail Domain boxes then save.
 [[image:instances02.JPG]]
 [[image:instances06.JPG]]
You've created your instance! congrats.
 [[image:instances05.JPG]]

See Also #

7433 Views , 0 Attachments 0 Attachments

Average (0 Votes)