28 Jan

Step by step installation of Liferay 6.1.1 CE GA2 on Ubuntu 12.04 LTS 64bit and JBoss 7… no bundle please!

liferay-logoIn this post is shared the installation of Liferay 6.1.1 Community Edition GA2 on Ubuntu 12.04 LTS 64bit with JBoss Application Server 7.1 Community Edition and PostgreSQL 8.4.15. The purpose installation is not the bundle one but the more “robust” alternative for an enterprise configuration.

As we like and prefer, the installation is a step by step list of commands and tasks… simpler to understand, to do and to test. Hope you’ll be agree.

Sources

In this paragraph are collected the used sources for the installation. I suggest to download and store them in a safe repository for future purposes (re-installation, maintainance, etc.).

Creation of a Virtual Machine with Ubuntu 12.04 LTS – 64bit – Desktop

For development purpose you should create your own environment on a virtual machine useful to customizations and tests. Of course if you are in a production environment you can jump directly to the next paragraph talking about the JDK installation.

In this case we use the Oracle VirtualBox as virtualization product but nothing should happen if you prefer VMPlayer or other solutions.

As first step, create the virtual machine with at least 2Gb RAM and start it using the ‘ubuntu-12.04.1-desktop-amd64.iso’ file. During the installation you receive some easy questions, driving you in the installation task.

Below some suggestions:

  • Admit downloading and installation of third party software and update during installation.
  • Machine name: liferay
  • Password: liferay
  • Launch update manager and reboot (more times until no update or errors). This task is not mandatory but suggested.
  • VirtualBoxMenu -> Devices -> Install Guest Additions
  • Open a terminal and execute:
sudo apt-get update
  • VirtualBoxMenu -> Devices -> Shared folders -> Add a new folder called ‘Desktop’ linked to your desktop.
  • Execute in the terminal:
sudo mount -t vboxsf Desktop /mnt
ls -la /mnt

The last command is done to check everything is properly set.

Java 1.7u9

  • Execute in the terminal:
sudo mkdir -p /opt/java
sudo chown liferay:liferay /opt/java
sudo cp -r /mn/.../jdk-7u9-linux-x64.tar.gz /opt/java
cd /opt/java
gunzip jdk-7u9-linux-x64.tar.gz
tar xvf jdk-7u9-linux-x64.tar
rm jdk-7u9-linux-x64.tar
sudo nano /etc/profile.d/java.sh

.

export JAVA_HOME=/opt/java/jdk1.7.0_09
export PATH=$PATH:$HOME/bin:$JAVA_HOME/bin
  • Exit saving the file content.
  • Exit from the user session (disconnect the user session) and reconnect again to receive the changes.
  • Open a terminal and execute the commands below to test if everything is properly set.
java -version
javac -version

Postgresql 8.4.15

We always prefer to compile PostgreSQL from the sources to have a full control of the installation and customizations.

  • Execute in the terminal:
sudo mkdir -p /opt/postgresql
sudo chown liferay:liferay /opt/postgresql
sudo cp /mnt/.../postgresql-8.4.15.tar.gz /opt/postgresql
cd /opt/postgresql
gunzip postgresql-8.4.15.tar.gz
tar xvf postgresql-8.4.15.tar
rm postgresql-8.4.15.tar
mkdir -p /opt/postgresql/8.4.15
cd /opt/postgresql/postgresql-8.4.15/
sudo apt-get install libreadline-dev
sudo apt-get install zlib1g-dev
./configure exec_prefix=/opt/postgresql/8.4.15
sudo make exec_prefix=/opt/postgresql/8.4.15
sudo make install exec_prefix=/opt/postgresql/8.4.15
  • Let’s create the data directory to store all data files and some configurations comprise defining the postgres user.
mkdir /opt/postgresql/8.4.15/data
mkdir /opt/postgresql/8.4.15/log
sudo adduser postgres
  • Use ‘postgres’. Other informations are optional.
sudo chown -R postgres:postgres /opt/postgresql
 su - postgres
  • Digit the password ‘postgres’.
nano .environment-8.4.15

.

export POSTGRES_VERSION=8.4.15
export LD_LIBRARY_PATH=/opt/postgres/${POSTGRES_VERSION}/lib
export PATH=/opt/postgres/${POSTGRES_VERSION}/bin:${PATH}
  • Exit from the editor saving the file content.
chmod 777 .environment-8.4.15
. .environment-8.4.15
/opt/postgresql/8.4.15/bin/initdb -D /opt/postgresql/8.4.15/data/ --encoding=UNICODE
exit
  • Back to the liferay user, let’s define some scripts used to manage the services.
sudo nano /etc/init.d/postgresql.8.4.15

.

case "$1" in

start)
 echo "Starting postgres"
 /bin/su - postgres -c "/home/postgres/postgresql-8.4.15 start"
 ;;
stop)
 echo "Stopping postgres"
 /bin/su - postgres -c "/home/postgres/postgresql-8.4.15 stop"
 ;;
* )
 echo "Usage: /sbin/service postgresql.8.4.15 {start|stop}"
 exit 1

esac

exit 0
  • Exit from the editor saving the file content.
sudo chmod 777 /etc/init.d/postgresql.8.4.15
su - postgres
  • Digit the password ‘postgres’.
. .environment-8.4.15
nano /home/postgres/postgresql-8.4.15

.

# Parameters: start or stop.
export POSTGRES_VERSION=8.4.15
# Check parameter.
if [ "$1" != "start" ] && [ "$1" != "stop" ]; then
 echo "Specify start or stop as first parameter."
 exit
fi

# Add stop switch.
__STOP_SWITCH=""
if [ "$1" = "stop" ]; then
 __STOP_MODE="smart"
 __STOP_SWITCH="-m $__STOP_MODE"
 echo "Stop switch is: $__STOP_SWITCH"

fi

# Do it.
export LD_LIBRARY_PATH=/opt/postgresql/${POSTGRES_VERSION}/lib
~/.environment-${POSTGRES_VERSION}
/opt/postgresql/${POSTGRES_VERSION}/bin/pg_ctl 
    -D /opt/postgresql/${POSTGRES_VERSION}/data 
    -l /opt/postgresql/${POSTGRES_VERSION}/log/postgresql.log 
    $1 $__STOP_SWITCH

# Alternative command.
# /opt/postgresql/${POSTGRES_VERSION}/bin/postgres -D /opt/postgresql/${POSTGRES_VERSION}/data
  • Exit from the editor saving the file content.
chmod 777 /home/postgres/postgresql-8.4.15
service postgresql.8.4.15 start
exit
  • Back to the liferay user, let’s create the database used from liferay.
su - postgres
  • Digit the password ‘postgres’.
. .environment-8.4.15
/opt/postgresql/8.4.15/bin/psql

.

CREATE ROLE liferay WITH PASSWORD 'liferay' LOGIN;
CREATE DATABASE lportal WITH OWNER liferay;
<ctrl> + d

.

/opt/postgresql/8.4.15/bin/psql -U liferay -d lportal
ALTER USER liferay WITH PASSWORD 'liferay';
<ctrl> + d

.

exit
  • Back to the liferay user.

JBoss AS 7.1 CE

Now it’s time to install JBoss Application Server Community Edition.

sudo mkdir /opt/liferay
sudo chown liferay:liferay /opt/liferay
cp /mnt/.../jboss-as-7.1.1.Final.tar.gz /opt/liferay
cd /opt/liferay
tar -xvf jboss-as-7.1.1.Final.tar.gz
rm -rf jboss-as-7.1.1.Final.tar.gz
sudo chown -R liferay:liferay /opt/liferay
mv /opt/liferay/jboss-as-7.1.1.Final /opt/liferay/jboss
cd /opt/liferay/jboss/bin
./add-user.sh

.

What type of user do you wish to add?
a) Management User (mgmt-users.properties)
b) Application User (application-users.properties)
(a): a

We select “a”, next you should see the following message:

Enter the details of the new user to add.
Realm (ManagementRealm) :
Username : jboss
Password : jb0ss
Re-enter Password : jb0ss
  • Done! Let’s start JBoss to test everything is working properly.
/opt/liferay/jboss/bin/standalone.sh -Djboss.bind.address=0.0.0.0 -Djboss.bind.address.management=0.0.0.0 &
  • Open your browser and access to ‘http://localhost:8080’ to test the default JBoss page is rendered. Test also the ‘http://localhost:9990’ (login:jboss, password:jb0ss) address.
  • Shutdown the server
/opt/liferay/jboss/bin/jboss-cli.sh --connect command=:shutdown

Liferay 6.1.1 Community Edition GA2 on JBoss

Not many documentations are well done like the Liferay ones. To this link the steps for JBoss installation of Liferay.

mkdir -p /opt/liferay/jboss/modules/com/liferay/portal/main
cd /opt/liferay/jboss/modules/com/liferay/portal/main
cp /mnt/.../liferay-portal-dependencies-6.1.1-ce-ga2-...zip .
unzip liferay-portal-dependencies-6.1.1-ce-ga2-...zip
rm -rf liferay-portal-dependencies-6.1.1-ce-ga2-...zip
mv liferay-portal-dependencies-6.1.1-ce-ga2/* .
rm -rf liferay-portal-dependencies-6.1.1-ce-ga2
cp /mnt/.../postgresql-8.4-703.jdbc4.jar .
nano /opt/liferay/jboss/modules/com/liferay/portal/main/module.xml

.

<?xml version="1.0"?>
<module xmlns="urn:jboss:module:1.0" name="com.liferay.portal">
    <resources>
       <resource-root path="postgresql-8.4-703.jdbc4.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>
  • Exit from the editor saving the file content.
nano /opt/liferay/jboss/modules/sun/jdk/main/module.xml

.

<!-- Add -->
<path name="com/sun/crypto"/>
<path name="com/sun/crypto/provider"/>
  • Exit from the editor saving the file content.
nano /opt/liferay/jboss/standalone/configuration/standalone.xml

.

...
<!-- Set the attribute with this value -->
... enable-welcome-root="false" ...
...
<subsystem xmlns="urn:jboss:domain:datasources:1.0">
  <datasources>
    <!-- Comment the hsql datasource -->
    <datasource jndi-name="java:jboss/datasources/PostgreSQLDS" enabled="true" use-java-context="true" pool-name="PostgreSQLDS" use-ccm="true">
      <connection-url>jdbc:postgresql://localhost:5432/lportal</connection-url>
      <driver>postgresql</driver>
      <security>
        <user-name>liferay</user-name>
        <password>liferay</password>
      </security>
    </datasource>
    ...
  </datasources>
  <drivers>
    ...
    <!-- Comment the hsql driver -->
    <driver name="postgresql" module="com.liferay.portal">
      <xa-datasource-class>org.postgresql.xa.PGXADataSource</xa-datasource-class>
    </driver>
    ...
  </drivers>
...
<subsystem xmlns="urn:jboss:domain:web:1.1" ... >
  ...
  <!-- Add this -->
  <configuration>
    <jsp-configuration development="true" />
  </configuration>
</subsystem>
...
<subsystem xmlns="urn:jboss:domain:deployment-scanner:1.1" ... >
  <deployment-scanner ... deployment-timeout="120"/>
</subsystem>
...
<subsystem xmlns="urn:jboss:domain:security:1.1" ... >
  <security-domains>
    ...
    <security-domain name="PortalRealm">
      <authentication>
        <login-module code="com.liferay.portal.security.jaas.PortalLoginModule" flag="required"/>
      </authentication>
    </security-domain>
    ...
  </security-domains>
</subsystem>
...
  • Exit from the editor saving the file content.
nano /opt/liferay/jboss/bin/standalone.conf

.

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

# ATTENTION: Remove from JAVA_OPTS the params defined before (if any).
...
  • Exit from the editor saving the file content.
mkdir -p /opt/liferay/jboss/standalone/deployments/ROOT.war
cd /opt/liferay/jboss/standalone/deployments/ROOT.war
cp /mnt/.../liferay-portal-6.1.1-ce-ga2-...war .
jar -xf liferay-portal-6.1.1-ce-ga2-...war
rm -rf liferay-portal-6.1.1-ce-ga2-...war
touch ../ROOT.war.dodeploy
rm -rf /opt/liferay/jboss/standalone/deployments/ROOT.war/WEB-INF/lib/eclipselink.jar
nano /opt/liferay/jboss/standalone/deployments/ROOT.war/WEB-INF/classes/portal-ext.properties

.

jdbc.default.jndi.name=java:jboss/datasources/PostgreSQLDS
  • Exit from the editor saving the file content.
nano /opt/liferay/portal-setup-wizard.properties

.

setup.wizard.enabled=false
  • Exit from the editor saving the file content.
  • Now it’s the time to start JBoss for the first time with Liferay. Could happen a failed deploy because of timeout of 120 seconds. In that case don’t worry… stop and restart again, everything will work properly!
/opt/liferay/jboss/bin/standalone.sh -Djboss.bind.address=0.0.0.0 -Djboss.bind.address.management=0.0.0.0 &
  • Open your browser and access to ‘http://localhost:8080’ to test if everything is working properly.
/opt/liferay/jboss/bin/jboss-cli.sh --connect command=:shutdown
sudo nano /etc/init.d/liferay

.

case "$1" in

start)
 /bin/su - liferay -c "/opt/liferay/jboss/bin/standalone.sh -Djboss.bind.address=0.0.0.0 -Djboss.bind.address.management=0.0.0.0 &"
 ;;
stop)
 /bin/su - liferay -c "/opt/liferay/jboss/bin/jboss-cli.sh --connect command=:shutdown"
 ;;
* )
 echo "Usage:service liferay {start|stop}"
 exit 1

esac

exit 0
  • Exit from the editor saving the file content.
sudo chmod 777 /etc/init.d/liferay
service liferay start

My personal compliments… Liferay on JBoss and PostgreSQL is installed with success!

4 thoughts on “Step by step installation of Liferay 6.1.1 CE GA2 on Ubuntu 12.04 LTS 64bit and JBoss 7… no bundle please!

  1. Very nice post! Little thing i noticed is Java 7. Not official supported by Liferay so far according to their site, so best to stick to Java 6. I’ve read on some side effects.

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.