Monday, November 4, 2013

Installing Liferay on JBoss 7

Today I will explain how to deploy liferay portal on JBoss 7. For this I am using a linux based system.

First we start by installing jdk.
Download the jdk from java.net from the link below,

wget http://download.java.net/jdk6/6u38/promoted/b04/binaries/jdk-6u38-ea-bin-b04-linux-i586-31_oct_2012.bin?q=download/jdk6/6u38/promoted/b04/binaries/jdk-6u38-ea-bin-b04-linux-i586-31_oct_2012.bin

Install the jdk in /usr/lib/jdk6/ , by unzipping and extracting the downloaded jdk to this folder.
Now create user jboss,
useradd -m jboss

su - jboss

vim /home/jboss/.profile

export PATH
JAVA_HOME=/usr/lib/jdk6/
export JAVA_HOME
PATH=$JAVA_HOME/bin:$PATH
export PATH
JBOSS_HOME=/opt/liferay/jboss
export JBOSS_HOME

source /home/jboss/.profile

Create jboss home,

mkdir /opt/liferay/jboss

Download the JBoss webprofile jboss-as-web-7.0.2.Final.zip from the jboss.org site.

Extract the jboss-as-web-7.0.2.Final.zip jboss webprofile to /opt/liferay/jboss

Download the latest version of the Liferay Portal .war file

 liferay-portal-6.1.2-ce-ga3-20130816114619181.war

Download Liferay’s Portal Dependencies,

 liferay-portal-dependencies-6.1.2-ce-ga3-20130816114619181.zip


Now extract the liferay-portal-dependencies-6.1.2-ce-ga3-20130816114619181.zip to /opt/liferay/jboss/modules/com/liferay/portal/main/ directory

I am using mysql as the backend database, So we need to download and install the proper mysql driver to this directory,

cp mysql-connector-java-5.0.8-bin.jar /opt/liferay/jboss/modules/com/liferay/portal/main/


Create a file module.xml in the /opt/liferay/jboss/modules/com/liferay/portal/main folder and add the following contents.

<?xml version="1.0"?>

<module xmlns="urn:jboss:module:1.0" name="com.liferay.portal">
    <resources>
       <resource-root path="mysql-connector-java-5.0.8-bin.jar" />
       <resource-root path="portal-service.jar" />
       <resource-root path="portlet.jar" />
    </resources>
    <dependencies>
       <module name="javax.api" />
       <module name="javax.mail.api" />
       <module name="javax.servlet.api" />
       <module name="javax.servlet.jsp.api" />
       <module name="javax.transaction.api" />
    </dependencies>
</module>

Thus we have configured all our jar files..

You must also make some modifications to your configuration and startup scripts as follows,

vim /opt/liferay/jboss/standalone/configuration/standalone.xml

  Disable the welcome root of the web subsystem’s virtual server default host by specifying enable-welcome-root="false".

<subsystem xmlns="urn:jboss:domain:web:1.0" default-virtual-server="default-host">
    <connector name="http" scheme="http" protocol="HTTP/1.1" socket-binding="http"/>
    <virtual-server name="default-host" enable-welcome-root="false">
       <alias name="localhost" />
       <alias name="example.com" />
    </virtual-server>
</subsystem>


Insert the following <configuration> element within the web subsystem element <subsystem xmlns="urn:jboss:domain:web:1.0" default-virtual-server="default-host">.

<configuration>
    <jsp-configuration development="true" />
</configuration>


Add a timeout for the deployment scanner by setting deployment-timeout="900" as seen in the excerpt below

<subsystem xmlns="urn:jboss:domain:deployment-scanner:1.0">
    <deployment-scanner name="default" path="deployments" scan-enabled="true" scan-interval="5000" relative-to="jboss.server.base.dir" deployment-timeout="900"/>
</subsystem>



Add the following JAAS security domain to the security subsystem <security-domains> defined in element <subsystem xmlns="urn:jboss:domain:security:1.0">.

<security-domain name="PortalRealm">
    <authentication>
       <login-module code="com.liferay.portal.security.jaas.PortalLoginModule" flag="required"/>
    </authentication>
</security-domain>


Now add the following JAVA_OPTS assignment one file below,

/opt/liferay/jboss/bin/standalone.conf

JAVA_OPTS="$JAVA_OPTS -Dfile.encoding=UTF-8 -Djava.net.preferIPv4Stack=true -Duser.timezone=GMT -Xmx1024m -XX:MaxPermSize=256m"


Database Configuration

For Boss to manage your data source, follow the instructions below,

vim /opt/liferay/jboss/standalone/configuration/standalone.xml , and add within the <datasources> element.

<datasource jndi-name="java:/jdbc/LiferayPool" pool-name="LiferayPool" enabled="true" jta="true" use-java-context="true" use-ccm="true">
  <connection-url> jdbc:mysql://localhost/lportal </connection-url>
   <driver> mysql</driver>
   <security>
    <user-name>username</user-name>
    <password>password</password>
    </security>
</datasource>
<drivers>
  <driver name="mysql" module="com.liferay.portal">
    <driver-class> com.mysql.jdbc.Driver </driver-class>
  </driver>
</drivers>


Be sure to replace the URL database value (i.e. lportal), user value and password value with values specific to your database.


Now configure your data source,

vim /opt/liferay/portal-ext.properties

  jdbc.default.jndi.name=java:jdbc/LiferayPool
  setup.wizard.enabled=false

Also create some folders in the liferay home folder,

cd /opt/liferay

mkdir data deploy logs ; chown jboss:jboss data deploy logs jboss -R

Now you’re ready to deploy Liferay Portal.

Create a new folder /opt/liferay/jboss/standalone/deployments/ROOT.war

Extract the downloaded file liferay-portal-6.1.2-ce-ga3-20130816114619181.war into the ROOT.war folder.

To trigger deployment of ROOT.war, create an empty file named ROOT.war.dodeploy in your /opt/liferay/jboss/standalone/deployments/ folder. On startup, JBoss detects the presence of this file and deploys it as a web application.

Now it’s time to start Liferay Portal on JBoss!

By defaults the port will be binded in localhost, edit standalone.xml for binding in all interfaces.

ie,

<interfaces>
        <interface name="management">
            <inet-address value="${jboss.bind.address.management:0.0.0.0}"/>
        </interface>
        <interface name="public">
            <inet-address value="${jboss.bind.address:0.0.0.0}"/>
        </interface>
</interfaces>

Start the server,

sudo -u jboss /opt/liferay/jboss/bin/standalone.sh

If the setup wizard was disabled, your site’s home page opens automatically in your browser at http://<ip>:8080. Otherwise, the setup wizard opens in your browser.


Thanks for reading,

Cheers/-

No comments:

Post a Comment