01 Feb

Step by step installation of Liferay 6.1.1 CE GA2 on Ubuntu 12.04 LTS 64bit and Tomcat 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 Apache Tomcat 7.0.35 and PostgreSQL 8.4.15. The purpose installation is not the bundle one but the more “robust” alternative for an enterprise configuration.

The post is based on the installation tutorial described in the ‘Step by step installation of Liferay 6.1.1 CE GA2 on Ubuntu 12.04 LTS and JBoss 7 64bit… no bundle please!‘ with the difference that in this case the installation is on Apache Tomcat instead of Jboss Application Server.

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.

Apache Tomcat 7.0.35

Now it’s time to install Apache Tomcat.

sudo mkdir /opt/liferay
sudo chown liferay:liferay /opt/liferay
cp /mnt/.../apache-tomcat-7.0.35.tar.gz /opt/liferay
cd /opt/liferay
tar -xvf apache-tomcat-7.0.35.tar.gz
rm -rf apache-tomcat-7.0.35.tar.gz
sudo mv apache-tomcat-7.0.35 /opt/liferay/tomcat
  • Done! Let’s start Tomcat to test everything is working properly.
/opt/liferay/tomcat/bin/startup.sh
  • Open your browser and access to ‘http://localhost:8080’ to test the default Apache page is rendered.
  • Shutdown the server
/opt/liferay/tomcat/bin/shutdown.sh

Liferay 6.1.1 Community Edition GA2 on Tomcat

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

mkdir /opt/liferay/tomcat/lib/ext
cd /opt/liferay/tomcat/lib/ext
cp /mnt/.../liferay-portal-dependencies-6.1.1-ce-ga2-...zip /opt/liferay/tomcat/lib/ext
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/*.jar .
rm -rf liferay-portal-dependencies-6.1.1-ce-ga2
  • Extract the Liferay src in a temporary folder. Starting from now we’ll call it $LIFERAY_SOURCE.
  • Copy from $LIFERAY_SOURCE/lib/development to your $TOMCAT_HOME/lib/ext: activation.jar, jms.jar, jta.jar, jutf7.jar, mail.jar, persistence.jar.
  • Copy from $LIFERAY_SOURCE/lib/portal to $TOMCAT_HOME/lib/ext: ccpp.jar.
mkdir -p /opt/liferay/tomcat/temp/liferay/com/liferay/portal/deploy/dependencies
  • Copy from $LIFERAY_SOURCE/lib/development to your $TOMCAT_HOME/temp/liferay/com/liferay/portal/deploy/dependencies: resin.jar, script-10.jar.
sudo cp /mnt/.../postgresql-8.4-703.jdbc4.jar $TOMCAT_HOME/lib/ext.
sudo cp /mnt/.../jta...jar $TOMCAT_HOME/lib/ext.
nano /opt/liferay/tomcat/bin/setenv.sh

.

JAVA_OPTS="$JAVA_OPTS -Dfile.encoding=UTF8 -Dorg.apache.catalina.loader.WebappClassLoader.ENABLE_CLEAR_REFERENCES=false -Duser.timezone=GMT -Xmx1024m -XX:MaxPermSize=256m"
  • Exit from the editor saving the file content.
mkdir -p /opt/liferay/tomcat/conf/Catalina/localhost
nano /opt/liferay/tomcat/conf/Catalina/localhost/ROOT.xml

.

<Context path="" crossContext="true">

<!-- JAAS -->

<!--<Realm
    className="org.apache.catalina.realm.JAASRealm"
    appName="PortalRealm"
    userClassNames="com.liferay.portal.kernel.security.jaas.PortalPrincipal"
    roleClassNames="com.liferay.portal.kernel.security.jaas.PortalRole"
/>-->

<!--
Uncomment the following to disable persistent sessions across reboots.
-->

<!--<Manager pathname="" />-->

<!--
Uncomment the following to not use sessions. See the property
"session.disabled" in portal.properties.
-->

<!--<Manager className="com.liferay.support.tomcat.session.SessionLessManagerBase" />-->

</Context>
  • Exit from the editor saving the file content.
nano /opt/liferay/tomcat/conf/catalina.properties
  • Replace:
common.loader=${catalina.base}/lib,${catalina.base}/lib/*.jar,${catalina.home}/lib,${catalina.home}/lib/*.jar

with:

common.loader=${catalina.base}/lib,${catalina.base}/lib/*.jar,${catalina.home}/lib,${catalina.home}/lib/*.jar,${catalina.home}/lib/ext,${catalina.home}/lib/ext/*.jar
  • Exit from the editor saving the file content.
nano /opt/liferay/tomcat/conf/server.xml
  • Modify with the …URIEncoding…:
<Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" URIEncoding="UTF-8" />
  • Exit from the editor saving the file content.
  • Make sure there is no support-catalina.jar file in your $TOMCAT_HOME/webapps directory. If you find one, remove it.
rm -rf /opt/liferay/tomcat/webapps/ROOT/*
cp liferay-portal-6.1.1-ce-ga2-...war /opt/liferay/tomcat/webapps/ROOT
cd /opt/liferay/tomcat/webapps/ROOT
jar -xf /opt/liferay/tomcat/webapps/ROOT/liferay-portal-6.1.1-ce-ga2-...war
rm /opt/liferay/tomcat/webapps/ROOT/liferay-portal-6.1.1-ce-ga2-...war
nano /opt/liferay/tomcat/webapps/ROOT/WEB-INF/classes/portal-ext.properties

.

jdbc.default.driverClassName=org.postgresql.Driver
jdbc.default.url=jdbc:postgresql://localhost:5432/lportal
jdbc.default.username=liferay
jdbc.default.password=liferay

setup.wizard.enabled=true
  • Exit from the editor saving the file content.
/opt/liferay/tomcat/bin/startup.sh
tail -f /opt/liferay/tomcat/logs/catalina.out
  • Browse configuration wizard at ‘http://localhost:8080’.
  • Set administrator with login:admin, password:admin. During nexts steps confirm ‘admin’ password.
nano /opt/liferay/tomcat/webapps/ROOT/WEB-INF/classes/portal-ext.properties

.

#setup.wizard.enabled=true
  • Exit from the editor saving the file content.
/opt/liferay/tomcat/bin/shutdown.sh
sudo nano /etc/init.d/liferay

.

case "$1" in

start)
 /bin/su - liferay -c "/opt/liferay/tomcat/bin/startup.sh"
 ;;
stop)
 /bin/su - liferay -c "/opt/liferay/tomcat/bin/shutdown.sh"

 ;;
* )
 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 Tomcat and PostgreSQL is installed with success!

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

  1. My personal compliments also, excellent lesson. And it’s exactly what was missing from the installation instruction of both sits Liferay and the more sofisticated Tomcat.
    I hope you don’t mind is I make reference to this post on other forums.
    Thank you Francesco

  2. can we use liferay bundled with tomcat in production environment(clustered) instead of deplying on externa tomcat?

    • Francesco Corti

      Hi Sashi,

      I’m always afraid on using bundled installations in production’s environment because in some advanced cases it’s quite difficoult to “control” and to know what is really happening.

      Of course this is a possible opinion (agreed from lot of professionists).

      Hope this help you in your choice.

  3. Thank you Francesco for quick reply. I have created a production environment with bundled installation(single app server), but when I am trying to increase the app servers and trying to start them, the database getting vanished. Any clue or standard steps to create clustered environment with bundle?

    • Francesco Corti

      You are welcome Shashi.

      I’m sorry but I would like to discourage you from installing a clustered liferay using the bundle. Sorry but I didn’t do that and I suggest you to get in touch with a professional service to support you in this task. 😉

      Sorry if I’m quite brute with this message but this is a personal blog and I prefer to be honest, transparent and professional because here there is my own face. 😉

    • Francesco Corti

      Hi,
      It strictly depends on the version you are using.
      Some could tell you that Ubuntu is less secure than CentOs (for example) but 14 LTS for me it’s ok.
      I hope this helps you.

Leave a Reply

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

Time limit is exhausted. Please reload CAPTCHA.