Install Alfresco on Ubuntu 14.04

Install alfresco on Ubuntu 14.04

I am going to write a post about how to install Alfresco on Ubuntu 14.04, I used a blog by fcorti.com so a lot of my information comes from this and I am by no means an Alfresco expert.

I went through the pain of the installation which was worth it.

I am going to try and aim this post at beginners like myself – some of the lower level points in fcorti’s  blog were not explained in huge detail for beginners so I am going to give it down to command level, and some of the software repositories were not available.

Full credit to fcorti.com as that was the only concise explanation I could find on the web how to do this install – for reference the blog is at https://fcorti.com/2014/10/13/how-to-install-alfresco-5-0-ubuntu-14-04-lts/

You can reference fcorti’s blog for a more detailed explanation my post is just going to be commands and steps.

This guide is based on Alfresco 5.0 a but I have read other posts explaining that it works also for 5.0 d – I will write another post once I upgrade.

To contribute to the community I am going to give the process I went through.

Lets Begin!

Prepare your OS for the install

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

Create the alfresco user

adduser alfresco
Enter new UNIX password: ****** (password of your choice)
adduser alfresco sudo

Get the java package to any location

sudo wget --no-check-certificate --no-cookies - --header "Cookie: oraclelicense=accept-securebackup-cookie" https://download.oracle.com/otn-pub/java/jdk/7u67-b01/jdk-7u67-linux-x64.tar.gz

Copy the java package to the correct location and extract

copy to /opt/java
sudo chmod a+x jdk-7u67-linux-x64.tar.gz
sudo gunzip jdk-7u67-linux-x64.tar.gz
sudo tar -xvf jdk-7u67-linux-x64.tar.gz

Using the editor of your choice add the below lines to your home .profile and /etc/profile.d/java.sh

export JAVA_HOME=/opt/java/jdk1.7.0_67
export PATH=$PATH:$HOME/bin:$JAVA_HOME/bin

Install ffmpeg

sudo add-apt-repository ppa:mc3man/trusty-media
sudo apt-get update
sudo apt-get dist-upgrade
sudo apt-get install ffmpeg

Install swftools

sudo apt-get install libjpeg62 libgif4 libart-2.0-2
wget https://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

Download postgres and create the user

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

Create the Afresco database

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>

Create the alfresco home directory and modify permissions

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

Get the tomcat package, un-compress, extract and rename it

cd /opt/alfresco
wget https://archive.apache.org/dist/tomcat/tomcat-7/v7.0.55/bin/apache-tomcat-7.0.55.tar.gz
gunzip apache-tomcat-7.0.55.tar.gz
tar -xvf apache-tomcat-7.0.55.tar
mv apache-tomcat-7.0.55 tomcat

Change ownership of tomcat, start it, check the java process, check the URL and shutdown if all is OK

sudo chown -R alfresco:alfresco /opt/alfresco/tomcat
/opt/alfresco/tomcat/bin/startup.sh
ps -ef | grep java
https://{your URL local or cloud}:8080/ (to check tomcat is available)
/opt/alfresco/tomcat/bin/shutdown.sh

Now for the Alfresco Install

Backup the tomcat properties file and edit the shared.loader line

cp /opt/alfresco/tomcat/conf/catalina.properties /opt/alfresco/tomcat/conf/catalina.properties.orig
vi /opt/alfresco/tomcat/conf/catalina.properties (or any editor you like - I like vi :))

ensure this line is present
shared.loader=${catalina.base}/shared/classes,${catalina.base}/shared/lib/*.jar

Backup the tomcat server file and edit

cp /opt/alfresco/tomcat/conf/server.xml /opt/alfresco/tomcat/conf/server.xml.orig
vi /opt/alfresco/tomcat/conf/server.xml (or any other editor)

Ensure the below connector section is the same as this

    <Connector port="8080" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443"
                URIEncoding="UTF-8" />

Modify the context.xml

vi /opt/alfresco/tomcat/conf/context.xml
Add the line below before </Context>

<Valve className="org.apache.catalina.authenticator.SSLAuthenticator" securePagesWithPragma="false" />

Create the Alfresco directory structure

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
mkdir -p /opt/alfresco/alf_data/keystore
mkdir -p /opt/alfresco/tmp

Download and unzip the Alfresco software

cd /opt/alfresco/tmp
wget https://sourceforge.net/projects/alfresco/files/Alfresco%205.0.a%20Community/alfresco-community-5.0.a.zip
unzip alfresco-community-5.0.a.zip

Copy the required extracted files into the relevant software locations

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/

Create a start open office file to be used by the daemon

vi /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 &
chmod uga+x /opt/alfresco/start_oo.sh
/opt/alfresco/start_oo.sh
ps -ef | grep soffice
killall soffice.bin
vi /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

Change the permissions of the Alfresco startup script

chmod uga+x /opt/alfresco/alfresco.sh

Create an alfresco deamon startup script and modify the permissions and owner

sudo vi /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

Create the alfresco data area

mkdir /opt/alfresco/alf_data

Backup the alfresco properties files and edit ensuring all the parameters are as below

cp /opt/alfresco/tomcat/shared/classes/alfresco-global.properties.sample /opt/alfresco/tomcat/shared/classes/alfresco-global.properties
vi /opt/alfresco/tomcat/shared/classes/alfresco-global.properties
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

Start the alfresco service and then tail the log and look closely for any errors

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

If everything is successful then stop the service, modify the parameter that tells alfresco to create the DB and restart

service alfresco stop
vi /opt/alfresco/tomcat/shared/classes/alfresco-global.properties
db.schema.update=false
service alfresco start

Not included in some of the blogs that I have read are gotchas below

Gotchas!

When I was installing when I tried to start alfresco after the install, during the Tomcat startup it hung at the deployment at some of the apps – there are many blogs and posts about deleting the unused Tomcat apps – I didn’t delete them I just moved them to a new ‘old’ folder

cd /opt/alfresco/tomcat/webapps
mkdir old
mv ROOT share share.war old

My cloud server started creaking at the heels once I started Tomcat up and started giving me all kinds of memory issues so another good one to limit the memory your Tomcat installation will use is to modify the JAVA_OPTS parameter in the Tomcat conf file.  Also you can adjust the memory settings as per your resources.

vi /opt/alfresco/tomcat/bin/catalina.sh

(Add this line as the first line in the file)

JAVA_OPTS="-Djava.awt.headless=true -Dfile.encoding=UTF-8 
-server -Xms512m -Xmx1024m
-XX:NewSize=512m -XX:MaxNewSize=512m -XX:PermSize=512m 
-XX:MaxPermSize=512m -XX:+DisableExplicitGC"

I know a lot of the information here is the same as the original blog I references, and I am not in the plagiarism business 🙂 but hopefully I added a few other points.  I will try and answer any questions I can around the installation in reference to my working installation.

Hope this helps, please share or comment if you found it useful!

Paul

IT consultant with 20+ years experience specialising in Oracle Database, Oracle Business Intelligence, Web/Mobile development, Application Express development, cloud technology and more

Leave a Reply

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