Alfresco on Ubuntu – Complete Installation Guide

In an earlier post, I had outlined the process of installing Alfresco on a 32-bit Ubuntu server. This walkthrough documents the steps required to get Alfresco going on a 64-bit machine running Ubuntu 10.04 LTS server, including installing and successfully establishing a connection with OpenOffice for document conversion and previews.


Pre-Requisites:

  • A machine running Ubuntu Server 10.04 LTS (64 bit) installed.

Installation of additional Alfresco components, such as solr, web quick start, web editor and sharepoint integration will not be covered in this walkthrough.

Prepping the system:

  1. Install MySQL server
    sudo apt-get install mysql-server
    

    During the installation, the installer will prompt you for the root password of the MySQL server.

  2. Login to MySQL, then setup the database and user account that Alfresco will use.

    create database alfresco;
    

    Next, generate a password for the alfresco user on the server.

    show create password('yourpassword');
    

    Make a note of the hash value that was generated. Finally, create the alfresco user account in MySQL and flush privileges for the changes to take effect.

    grant all privileges on `alfresco`.* to 'alfresco'@'localhost' identified by password '*YOURGENERATEDHASH';
    flush privileges;
    
  3. Install either the Sun(Oracle) or OpenJDK6 (1.8+) JVM. Alfresco will run fine on either of them, and performance will be similar, so choosing one over the other is a matter of personal preference.

    To install OpenJDK, if it isn’t already installed for some reason:

    sudo apt-get install openjdk6-jre
    

    Note that Alfresco 4.2+ only works on OpenJDK version 7 and up.

    If you prefer the Sun (now Oracle) JVM, run the following commands instead.

    sudo add-apt-repository ppa:webupd8team/java
    sudo apt-get update
    sudo apt-get install oracle-java7-installer
    
  4. Install OpenOffice and friends

    sudo apt-get install openoffice.org-base openoffice.org-base-core openoffice.org-calc openoffice.org-common openoffice.org-draw openoffice.org-impress openoffice.org-math openoffice.org-style-galaxy openoffice.org-style-human openoffice.org-style-industrial openoffice.org-style-oxygen openoffice.org-style-tango openoffice.org-writer openoffice.org ooo-thumbnailer
    

    The full open office suite (minus the GUI, dictionaries and language packs) is required for document conversions to work properly.

  5. Install Swftools. Alfresco uses the pdf2swf binary contained therin to generate previews for PDF files in Share.
    sudo apt-get install python-software-properties
    sudo apt-add-repository ppa:guilhem-fr/swftools
    sudo apt-get update
    sudo apt-get install swftools
    
  6. Install JODConverter.

    sudo apt-get install jodconverter jodconverter-java
    
  7. Install ImageMagick.

    sudo apt-get install imagemagick
    
  8. Install Microsoft core fonts, as these may be used by some documents and are required for converted documents to retain formatting.
    sudo apt-get install ttf-mscorefonts-installer
    
  9. Download the latest version of Apache Tomcat:

    wget http://apache.mirror.rafal.ca/tomcat/tomcat-7/v7.0.32/bin/apache-tomcat-7.0.32.tar.gz
    
  10. Download the Java MySQL drivers (Connector/J) from the MySQL website.

    wget http://cdn.mysql.com/Downloads/Connector-J/mysql-connector-java-5.1.22.tar.gz
    
  11. Finally, download the latest version of Alfresco. Visit this page, then click on “Custom Installs & Optional Modules”. Download the “alfresco-community-4.x.x.zip” file with wget.
    wget  http://dl.alfresco.com/release/community/build-4428/alfresco-community-4.2.a.zip
    
  12. We will be installing Alfresco in /opt/webapps, but you could choose any directory of your liking, including a user’s home directory. Just make sure you update the path in the scripts below. It is also advisable to create a separate user account on the system with restricted privileges that will under which the tomcat process will be executed, and also possibly fronted by Apache. These configurations are beyond the scope of this discussion. It is however worth mentioning that this user must be granged ownership to the chosen installation folder.

Installing Alfresco

Setting up and testing Tomcat

Extract Tomcat from the downloaded zip file into the target installation folder. Rename this folder to Tomcat. Test that it works by itself by executing bin/startup.sh. You should be able to access the default page by navigating to :8080 from a web browser in a computer on your network. If all is well, stop Tomcat by executing bin/shutdown.sh

Now that we know Tomcat works fine by itself, we will have to tweak it a bit for it to play nice hosting Alfresco.

  1. Create the file tomcat/conf/Catalina/localhost/alfresco.xml with the following contents:
    <?xml version="1.0" encoding="UTF-8"?>
    <Context>
      <Environment override="false" type="java.lang.Boolean" name="properties/startup.enable" description="A flag that globally enables or disables startup of the major Alfresco subsystems." value="true"/>
      <Environment override="false" type="java.lang.String" name="properties/dir.root" description="The filesystem directory below which content and index data is stored. Should be on a shared disk if this is a clustered installation."/>
      <Environment override="false" type="java.lang.String" name="properties/hibernate.dialect" description="The fully qualified name of a org.hibernate.dialect.Dialect subclass that allows Hibernate to generate SQL optimized for a particular relational database. Choose from org.hibernate.dialect.DerbyDialect, org.hibernate.dialect.MySQLInnoDBDialect, org.alfresco.repo.domain.hibernate.dialect.AlfrescoOracle9Dialect, org.alfresco.repo.domain.hibernate.dialect.AlfrescoSybaseAnywhereDialect, org.alfresco.repo.domain.hibernate.dialect.AlfrescoSQLServerDialect, org.hibernate.dialect.PostgreSQLDialect"/>
      <Environment override="false" type="java.lang.String" name="properties/hibernate.query.substitutions" description="Mapping from tokens in Hibernate queries to SQL tokens. For PostgreSQL, set this to &quot;true TRUE, false FALSE&quot;."/>
      <Environment override="false" type="java.lang.Boolean" name="properties/hibernate.jdbc.use_get_generated_keys" description="Enable use of JDBC3 PreparedStatement.getGeneratedKeys() to retrieve natively generated keys after insert. Requires JDBC3+ driver. Set to false if your driver has problems with the Hibernate identifier generators. By default, tries to determine the driver capabilities using connection metadata."/>
      <Environment override="false" type="java.lang.String" name="properties/hibernate.default_schema" description="Qualify unqualified table names with the given schema/tablespace in generated SQL. It may be necessary to set this when the target database has more than one schema."/>
    </Context>
    
  2. Edit catalina.properties in Tomcat’s conf folder and locate the line
    shared.loader=

    and change it to

    shared.loader=${catalina.base}/shared/classes,${catalina.base}/shared/lib/*.jar
Deploying Alfresco and Share on Tomcat
  1. Unzip the alfresco.zip file that you downloaded previously into a folder in your home directory
  2. Copy the endorsed folder into the Tomcat directory.
  3. Copy the files in the lib folder into the lib folder in the tomcat directory.
  4. Copy the war files in the webapps directory to tomcat’s webapps directory.
  5. Copy the shared folder into the tomcat directory.
  6. Extract the MySQL Connector/J jar you downloaded earlier and copy it into Tomcat’s lib folder.
  7. Create a directory named data in the root install directory, which will be Alfresco’s main data directory. When writing backup scripts, make sure this directory is backed up above all else!
Alfresco Utility Scripts

We will use three scripts, alfresco.sh, alf_start.sh and alf_stop.sh to aid in starting and stopping the server. These files are not included in the custom install version of Alfresco that we downloaded, and will have to be created in root install directory. Once created, these files will have to be made executable. This can by done by the chmod command:

chmod +x filename.sh

alfresco.sh

#!/bin/sh
# Start or stop Alfresco server
# Set the following to where Tomcat is installed
ALF_HOME=/opt/webapps/alfresco
cd "$ALF_HOME"
APPSERVER="${ALF_HOME}/tomcat"
export JAVA_HOME="/usr/lib/jvm/java-7-oracle/"
# Set any default JVM values
export JAVA_OPTS='-server -Xms2G -Xmx3G -XX:MaxPermSize=2048M -XX:NewSize=1024m'
export JAVA_OPTS="${JAVA_OPTS} -Dalfresco.home=${ALF_HOME} -Dcom.sun.management.jmxremote"
export JAVA_OPTS="${JAVA_OPTS} -Djava.rmi.server.hostname=localhost"
export JAVA_OPTS="${JAVA_OPTS} -Djava.awt.headless=true"
#
if [ "$1" = "start" ]; then
  "${APPSERVER}/bin/startup.sh"
elif [ "$1" = "stop" ]; then
  "${APPSERVER}/bin/shutdown.sh"
fi

You can tweak the VM options passed to better suit your environment. Note that if you installed OpenJDK, you will have to modify the JAVA_HOME variable as well (usually /usr/lib/jvm/java-7-openjdk).

alf_start.sh

#!/bin/sh
bash /opt/webapps/alfresco/alfresco.sh start

alf_stop.sh

#!/bin/sh
bash /opt/webapps/alfresco/alfresco.sh stop

Configuring the Alfresco Installation

Finally, we edit alfresco-global.properties, which is Alfresco’s primary configuration file, and includes database connection properties, indexer configuration, ftp and cifs configuration and the location of binaries of supporting libraries such as OpenOffice among others. The file is located under tomcat/shared/classes. A sample properties file is also provided for reference.

After a bit of tweaking, my alfresco-global.properties looked like this. The file is self-explanatory with the included comments.

###############################
## Common Alfresco Properties #
###############################
#
# custom content and index data location
#
dir.root=/opt/alfresco/data
#dir.keystore=${dir.root}/keystore
# we are not using solr yet, and will use lucene for the time being
index.subsystem.name=lucene
#
# Sample database connection properties
#
db.name=alfresco
db.host=localhost
db.port=3306
db.username=yourdbusername
db.password=yourdbpassword
db.driver=org.gjt.mm.mysql.Driver
db.url=jdbc:mysql://${db.host}:${db.port}/${db.name}
#
# External locations
#-------------
ooo.exe=/usr/lib/openoffice/program/soffice
ooo.enabled=true
jodconverter.officeHome=/usr/lib/openoffice
jodconverter.portNumbers=8101
jodconverter.enabled=true
img.root=/usr
swf.exe=/usr/bin/pdf2swf
#
# Index Recovery Mode
#-------------
index.recovery.mode=AUTO
#
# URL Generation Parameters (The ${localname} token is replaced by the local server name)
#-------------
alfresco.context=alfresco
alfresco.host=${localname}
alfresco.port=8080
alfresco.protocol=http
#
share.context=share
share.host=${localname}
share.port=8080
share.protocol=http
# Cifs settings to use non-privileged ports, as tomcat runs as non-root
# @see https://forums.alfresco.com/en/viewtopic.php?f=8&t=20893
cifs.enabled=true
cifs.Server.Name={localname}
cifs.domain=WORKGROUP
cifs.hostanounce=true
cifs.broadcast=0.0.0.0
cifs.tcpipSMB.port=50601
cifs.ipv6.enabled=false
cifs.netBIOSSMB.namePort=50602
cifs.netBIOSSMB.datagramPort=50603
cifs.netBIOSSMB.sessionPort=50604
# FTP
# Move the default ftp server port to a port over 1024 to avoid having to run tomcat with elevated privileges.
ftp.enabled=true
ftp.port=2121

That pretty much sums up all the configuration that is needed to get Alfresco up and running on an Ubuntu server. To start the server, simply execute alf_start.sh and tail Tomcat’s logs to make sure everything starts up smoothly.

Init Scripts To Automatically Start / Stop Alfresco during Server Reboot Cycles

One final piece of configuration is to add some init scripts to the server, to make sure tomcat is properly started / stopped when the server power cycles. This is done by creating an init script (which I have named alfresco) in /etc/init.d, and then using the update-rd.d tool to update the run levels on the server. Note that the example file below also attempts to start / stop the server as a non-privileged user named alfresco

#!/bin/sh
#
# description: Alfresco Community Startup Script
# adapted by JD
#
RETVAL=0
start () {
    sudo -u alfresco /opt/webapps/alfresco/alfresco.sh start "$2"
    RETVAL=$?
}
stop () {
    sudo -u alfresco /opt/webapps/alfresco/alfresco.sh stop "$2"
    RETVAL=$?
}
case "$1" in
    start)
        start "$@"
        ;;
    stop)
        stop "$@"
        ;;
    restart)
        stop "$@"
        start "$@"
        ;;
    *)
        sudo -u alfresco /opt/webapps/alfresco/alfresco.sh "$@"
        RETVAL=$?
esac
exit $RETVAL

Finally, run update-rc.d to update the run levels.

update-rc.d alfresco defaults

And thats all there is to manually installing Alfresco on a 64-bit Ubuntu server.

Leave a Reply

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


2 × two =

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>