How to install Alfresco 5.0.a Community Edition on Ubuntu 14.04 LTS

alfresco logoAfter the development of my most viewed post sharing how to install Alfresco 4.2.c on Ubuntu 10.04 LTS (more than 35.000 views) and Windows Server 2008 R2 (more that 13.000 views), it’s time to update the tutorial to the newest major version of Alfresco: Alfresco Community Edition 5.0.a. Even if the 5-th version is quite different from the 4-th version, the installation process is more or less the same… but let’s describe exactly the differences. The operating system choosen for the tutorial is Ubuntu 14.04.01 LTS.

Differently from the other post, the tutorial is separated in two parts: the installation of the dependencies and the Alfresco installation. 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.

Part 1 – Installation of the dependencies

Starting from a vanilla installation of Ubuntu O.S. 14.04.01 LTS, let’s update the libraries and configurations.

sudo apt-get update
sudo apt-get upgrade
sudo apt-get purge openjdk-\*

Now it’s time to add a new user called alfresco, we will use for the installation (password: alfresco).

adduser alfresco
Enter new UNIX password: alfresco

Starting from now we will work as alfresco user.

su – alfresco

JDK 1.7u67

Even if Alfresco 5.0.a is certified with Java1.7U60, we use Java1.7U67 (nothing serious will happen). You can download the package from Oracle Java SE Downloads. In our case the package is ‘jdk-7u67-linux-x64.tar.gz’.

sudo mkdir -p /opt/java

Unzip the package in it. In our case in the ‘/opt/java/jdk1.7.0_67’. Please remember to set the permits to the folder to ‘execute’ (use can use chmod command).

sudo nano /etc/profile.d/java.sh
export JAVA_HOME=/opt/alfresco/java/jdk1.7.0_67
export PATH=$PATH:$HOME/bin:$JAVA_HOME/bin

Save and exit.

java -version

ImageMagick

sudo apt-get install ghostscript imagemagick
convert --version

Using the command ‘whereis convert’, please check the result is ‘/usr/bin/convert’. If not, copy and use it in the ‘img.exe’ parameter into the alfresco-global.properties file.

FFMPeg

sudo add-apt-repository ppa:jon-severinsson/ffmpeg
sudo apt-get update
sudo apt-get install ffmpeg

SWFTools

sudo apt-get install libjpeg62 libgif4
wget http://archive.canonical.com/ubuntu/pool/partner/s/swftools/swftools_0.9.0-0ubuntu2_amd64.deb
chmod a+x swftools_0.9.0-0ubuntu2_amd64.deb
sudo dpkg -i swftools_0.9.0-0ubuntu2_amd64.deb

Using the command ‘whereis pdf2swf’, please check the result is ‘/usr/bin/pdf2swf’. If not, copy and use it in the ‘swf.exe’ parameter into the alfresco-global.properties file.

LibreOffice

sudo apt-get install libreoffice

Using the command ‘whereissoffice’, please check the result is ‘/usr/bin/soffice’. If not, copy and use it in the ooo.exe’ and ‘jodconverter.officeHome’ parameters into the alfresco-global.properties file.

PostgreSql

Even if Alfresco 5.0.a is certified with PostgreSql 9.2.4, we use PostgreSql 9.3.5 (nothing serious will happen).

sudo apt-get install postgresql postgresql-contrib
sudo passwd postgres
postgres

Now it’s time to prepare the (empty) database schema for Alfresco.

sudo -u postgres psql postgres
CREATE ROLE alfresco WITH PASSWORD 'alfresco' LOGIN;
CREATE DATABASE alfresco WITH OWNER alfresco;
<ctrl+d>
sudo -u alfresco psql alfresco
ALTER USER alfresco WITH PASSWORD 'alfresco';
<ctrl+d>

Tomcat

Even if Alfresco 5.0.a is certified with Tomcat 7.0.53, we use Tomcat 7.0.55 (nothing serious will happen). You can download the package from Apache Tomcat. In our case the package is ‘apache-tomcat-7.0.55.tar.gz’.

sudo mkdir -p /opt/alfresco
sudo chown alfresco:alfresco /opt/alfresco

Unzip the package in ‘/opt/alfresco’ renaming the apache-tomcat folder in ‘tomcat’.

sudo chown -R alfresco:alfresco /opt/alfresco/tomcat
/opt/alfresco/tomcat/bin/startup.sh
ps -ef | grep java

You can check the existence of the java process. Alternatively you can access to http://localhost:8080/ using your browser.

/opt/alfresco/tomcat/bin/shutdown.sh

Part 2 – Installation of Alfresco

Now that everything is ready, we can proceed to install Alfresco into the environment.

Alfresco 5.0.a

cp /opt/alfresco/tomcat/conf/catalina.properties /opt/alfresco/tomcat/conf/catalina.properties.orig
nano /opt/alfresco/tomcat/conf/catalina.properties

Set the ‘shared.loader’ parameter with the value described below.

shared.loader=${catalina.base}/shared/classes,${catalina.base}/shared/lib/*.jar

Save and exit.

cp /opt/alfresco/tomcat/conf/server.xml /opt/alfresco/tomcat/conf/server.xml.orig
nano /opt/alfresco/tomcat/conf/server.xml

Add ‘URIEncoding=”UTF-8″‘ to ‘<Connector port=”8080″ protocol=”HTTP/1.1″…’.

 nano /opt/alfresco/tomcat/conf/context.xml

Add the line below:

<Valve className="org.apache.catalina.authenticator.SSLAuthenticator" securePagesWithPragma="false" />
mkdir -p /opt/alfresco/tomcat/shared
mkdir -p /opt/alfresco/tomcat/shared/classes
mkdir -p /opt/alfresco/tomcat/shared/lib
mkdir -p /opt/alfresco/tomcat/endorsed

Download Alfresco Community Edition from Sourceforge. The package is named ‘alfresco-community-5.0.a.zip’. Unzip the package in a temporary folder and you will find a folder named ‘alfresco-community-5.0.a’.

cd .../alfresco-community-5.0.a
cp -R bin /opt/alfresco
cp -R web-server/endorsed/* /opt/alfresco/tomcat/endorsed
cp -R web-server/shared/* /opt/alfresco/tomcat/shared
cp -R web-server/lib/* /opt/alfresco/tomcat/lib
cp -R web-server/webapps/* /opt/alfresco/tomcat/webapps/

You can remove the folder named ‘alfresco-community-5.0.a’.

nano /opt/alfresco/start_oo.sh
#!/bin/sh -e

SOFFICE_ROOT=/usr/bin
"${SOFFICE_ROOT}/soffice" "--accept=socket,host=localhost,port=8100;urp;StarOffice.ServiceManager" --nologo --headless &

Save and exit.

chmod uga+x /opt/alfresco/start_oo.sh
/opt/alfresco/start_oo.sh
ps -ef | grep soffice

You can check the existence of the soffice process.

killall soffice.bin
nano /opt/alfresco/alfresco.sh
#!/bin/sh -e

# Start or stop Alfresco server

# Set the following to where Tomcat is installed
ALF_HOME=/opt/alfresco
cd "$ALF_HOME"
APPSERVER="${ALF_HOME}/tomcat"
export CATALINA_HOME="$APPSERVER"

# Set any default JVM values
export JAVA_OPTS='-Xms512m -Xmx768m -Xss768k -XX:MaxPermSize=256m -XX:NewSize=256m -server'
export JAVA_OPTS="${JAVA_OPTS} -Dalfresco.home=${ALF_HOME} -Dcom.sun.management.jmxremote"

if [ "$1" = "start" ]; then
 "${APPSERVER}/bin/startup.sh"
 if [ -r ./start_oo.sh ]; then
  "${ALF_HOME}/start_oo.sh"
 fi
elif [ "$1" = "stop" ]; then
 "${APPSERVER}/bin/shutdown.sh"
 killall -u alfresco java
 killall -u alfresco soffice.bin
fi
chmod uga+x /opt/alfresco/alfresco.sh
sudo nano /etc/init.d/alfresco
 #!/bin/sh -e

ALFRESCO_SCRIPT="/opt/alfresco/alfresco.sh"

if [ "$1" = "start" ]; then
 su - alfresco "${ALFRESCO_SCRIPT}" "start"
elif [ "$1" = "stop" ]; then
 su - alfresco "${ALFRESCO_SCRIPT}" "stop"
elif [ "$1" = "restart" ]; then
 su - alfresco "${ALFRESCO_SCRIPT}" "stop"
 su - alfresco "${ALFRESCO_SCRIPT}" "start"
else
 echo "Usage: /etc/init.d/alfresco [start|stop|restart]"
fi
sudo chmod uga+x /etc/init.d/alfresco
sudo chown alfresco:alfresco /etc/init.d/alfresco
mkdir /opt/alfresco/alf_data
cp /opt/alfresco/tomcat/shared/classes/alfresco-global.properties.sample /opt/alfresco/tomcat/shared/classes/alfresco-global.properties
nano /opt/alfresco/tomcat/shared/classes/alfresco-global.properties

Below the lines to replace or add to the properties file.

dir.root=/opt/alfresco/alf_data
...
db.username=alfresco
db.password=alfresco
...
# OpenOffice
ooo.exe=/usr/lib/libreoffice/program/soffice.bin
ooo.enabled=true
jodconverter.officeHome=/usr/lib/libreoffice
jodconverter.portNumbers=8100
jodconverter.enabled=true
# ImageMagick installation
img.root=/usr/share/doc/imagemagick
img.exe=/usr/bin/convert
# SWFTools exe
swf.exe=/usr/bin/pdf2swf
...
db.schema.update=true
...
db.driver=org.postgresql.Driver
db.url=jdbc:postgresql://localhost:5432/alfresco
...
index.recovery.mode=AUTO
...
authentication.chain=alfrescoNtlm1:alfrescoNtlm

Now everything is ready to start alfresco but, please, pay attention now. Check very carefully the log during the first run. Pay attention to the ERRORS and the reasons why the errors are thrown.

service alfresco start
tailf /opt/alfresco/tomcat/logs/catalina.out

For example, the lines below are caused by the missing configuration of FTP and CIFS. Enjoy!

2014-09-22 22:01:32,203 ERROR [org.alfresco.fileserver] [FTP Server] [FTP] FTP Socket error : java.net.BindException: Permission denied
...
2014-09-22 22:01:32,210 ERROR [org.alfresco.fileserver] [CIFS Server] [SMB] Server error : org.alfresco.jlan.server.config.InvalidConfigurationException: Error initializing TCP-IP SMB session handler, Permission denied

ffmpeg for Ubuntu 14.04 LTS (mandatory for Alfresco)

ffmpegIn a past tutorial (one of the most accessed post of the blog) I shared a step by step tutorial describing the installation of Alfresco using an more controlled and “enterprise” approach respect to the bundle. The tutorial referrers to Alfresco Community Edition 4.2.c on Ubuntu 12.04 LTS and few days ago has been released the brand new Ubuntu 14.04 LTS Operating System.

Installing Alfresco as usual, I have found the FFmpeg is not included in the Ubuntu repositories and it has been replaced by libav (an ffmpeg fork of the project). For further details, you can read something here:

http://askubuntu.com/questions/432542/is-ffmpeg-missing-from-the-official-repositories-in-14-04

Waiting for an official answer from Alfresco, I found how to solve the problem. In particular, how to install ffmpeg on Ubuntu 14.04 LTS that is mandatory to make Alfresco works.

Other instructions on how to install Alfresco 4.2.f on Ubuntu 14.04 LTS are similar to the tutorial, so I don’t want to repeat them here (probably I’ll refresh the post in the future).

Coming to the solution…

To install ffmpeg on Ubuntu 14.04 LTS you have simply to open a terminal and execute the commands described below.

sudo apt-add-repository ppa:mc3man/trusty-media
sudo apt-get update
sudo apt-get install ffmpeg gstreamer0.10-ffmpeg

I hope this information will help you to install Alfresco with success in your environment. 😉

Francesco Corti

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
/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&#8217;.
  • 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!

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 &
/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 &
/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!