Friday, June 26, 2015

OpenKM Setup from Scratch on Ubuntu Server 14.04

First I am not an expert, but want to share my experience and hope you all can get shorter to your KM goal.  So please forgive me if any stupid thing did here and mistakes found...

After studying the OpenKM for a couple weeks, I have successfully to setup the OpenKM on a total new installed Ubuntu Server only using the OpenKM's configuration files and the WAR.

My Target:
1. Deploy OpenKM with only a WAR file on New Installed Ubuntu/Tomcat
2. Implement MySQL instead of HSQL
3. Implement all preview functions for PDFs/Office Documents/Image/Videos...
4. Implement the anti-virus function

Detail Setup Guide:
Step 1 - OS Setup



Step 2 - OS Network Configuration




Step 3 - SSH Client with Putty




Step 4 - OpenKM Setup (NOTE: typing mistakes in video MySQL5InnoDBDialect during setup OpenKM.cfg)





Step 5 - OpenKM Testing





Finished!!!


(you can get the following notes for the videos, with it you can copy/paste commands simply for your personal trial.  Of course, remember to change my name to your name... haha..., Enjoy it.!!!)

Notes for OpenKM Installation on Ubuntu

Step 1 - OS Setup

Follow the wizard and remember to Select install “OpenSSH” only


Step 2 - OS Network Configuration

$ sudo bash
# vi /etc/network/interfaces
iface eth0 inet static
address 188.4.72.198
network 255.255.255.0
gateway 188.4.72.231

# /etc/resolvconf/resolv.conf.d/base
nameserver 188.4.72.16
nameserver 188.4.72.7

# resolvconf -u



Step 3 - OpenKM Setup

Installing MySQL Server
# apt-get install mysql-server

after that it will prompt you to input the Master password for MYSQL server (input and REMEMBER IT……)

Installing Tomcat7 Server
# apt-get install libtcnative-1 libtomcat7-java tomcat7 tomcat7-admin tomcat7-common tomcat7-docs tomcat7-examples tomcat7-user

# apt-get install unzip
# wget http://liquidtelecom.dl.sourceforge.net/project/openkm/6.3/openkm-6.3.0-community-tomcat-bundle.zip

# unzip openkm-6.3.0-community-tomcat-bundle.zip


Configuration MySQL Server (Optional)

# vi /etc/mysql/my.cnf and


under [mysqld] section in your ini file, add:

    default-storage-engine = innodb




Check if your MySQL installation has InnoDB engine enabled:


# service mysql restart

# mysql -h localhost -u root -p
mysql> show engines;

and continue create OpenKM db in mysql tool (remember to change your password)

CREATE DATABASE okmdb DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_bin;
CREATE USER openkm@localhost IDENTIFIED BY 'okmtest123';
GRANT ALL ON okmdb.* TO openkm@localhost WITH GRANT OPTION;



Build some Links
# ln -s /var/lib/tomcat7/common /usr/share/tomcat7/common
# ln -s /var/lib/tomcat7/server /usr/share/tomcat7/server
# ln -s /var/log/tomcat7 /usr/share/tomcat7/logs
# ln -s /var/lib/tomcat7/repository /usr/share/tomcat7/repository
# ln -s /etc/tomcat7 /usr/share/tomcat7/conf


Preparing OpenKM.cfg
# cp /home/kevinchui/tomcat/OpenKM.cfg /usr/share/tomcat7

modify the line in file /usr/share/tomcat7/OpenKM.cfg (note that in the video, it was wrongly typed as "i" which should be capitalized in MySQL5InnoDBDialect)
    hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect
    hibernate.hbm2ddl=create


Preparing OpenKM.xml, PropertyGroups

# cp /home/kevinchui/tomcat/OpenKM.xml /usr/share/tomcat7
# cp /home/kevinchui/tomcat/PropertyGroups.xml /usr/share/tomcat7


Preparing setenv.sh (Environment Setting)
# cp /home/kevinchui/tomcat/bin/setenv.sh /usr/share/tomcat7/bin

Remark the line in file /usr/share/tomcat7/bin/setenv.sh
        #CATALINA_PID=$CATALINA_HOME/catalina.pid


Preparing lib for OpenKM

# cp /home/kevinchui/tomcat/lib/javassist-*.jar /usr/share/tomcat7/lib
# cp /home/kevinchui/tomcat/lib/jstl-1.2.jar /usr/share/tomcat7/lib
# cp /home/kevinchui/tomcat/lib/jta-1.1.jar /usr/share/tomcat7/lib
# cp /home/kevinchui/tomcat/lib/log4j-1.2.17.jar /usr/share/tomcat7/lib
# cp /home/kevinchui/tomcat/lib/log4j-initializer.jar /usr/share/tomcat7/lib
# cp /home/kevinchui/tomcat/lib/mail-1.*.jar /usr/share/tomcat7/lib
# cp /home/kevinchui/tomcat/lib/mysql-connector-java-5.1.12-bin.jar /usr/share/tomcat7/lib
# cp /home/kevinchui/tomcat/lib/tomcat-juli-adapters.jar /usr/share/tomcat7/lib
# cp /home/kevinchui/tomcat/lib/unicode.ttf /usr/share/tomcat7/lib
# cp /home/kevinchui/tomcat/lib/sigar /usr/share/tomcat7/lib/sigar -R
# cp /home/kevinchui/tomcat/lib/hsqldb.jar /usr/share/tomcat7/lib/

Preparing log4j configuration
# cp /home/kevinchui/tomcat/conf/log4j.properties /etc/tomcat7



Configurating context.xml

# vi /etc/tomcat7/context.xml
find the follwing line
        WEB-INF/web.xml
and add the following lines after it
        
        


Configurating server.xml
# vi /etc/tomcat7/server.xml
find the follwing line
   
and add the following lines after it
   
   

then find the follwing line
   
and add the following 7 lines after it
          maxActive="100" maxIdle="30" maxWait="10000" validationQuery="select 1"
          username="openkm" password="okmtest123" driverClassName="com.mysql.jdbc.Driver"
          url="jdbc:mysql://localhost:3306/okmdb?autoReconnect=true&useUnicode=true&characterEncoding=UTF8"/>

            mail.smtp.host="localhost" mail.from="testing@openkm.com"/>


then find and Modify the line
FROM:
   

 TO:
   



Set directories privileges
# chown tomcat7.tomcat7 /usr/share/tomcat7 /var/lib/tomcat7 /etc/tomcat7/* -R


Deploying OpenKM.war
# service tomcat7 stop
# cp /home/kevinchui/tomcat/webapps/OpenKM.war /var/lib/tomcat7/webapps/


Implement the rest
# apt-get install libreoffice imagemagick clamav clamav-daemon

Update the Virus Definitions
# freshclam

Prepareing SWFTOOLS
# cp /home/kevinchui/tomcat/bin/pdf2swf /usr/bin


Start TOMCAT server
# service tomcat7 start



OpenKM additional Configurations for Preview/Antivirus
Login OpenKM -> Administration -> Configuration and set the followings.

system.openoffice.path
/usr/lib/libreoffice

system.imagemagick.convert
/usr/bin/convert

system.swftools.pdf2swf
/usr/bin/pdf2swf -f -T 9 -t -s storeallcharacters ${fileIn} -o ${fileOut}

system.webdav.fix
true
system.webdav.server
true

system.ghostscript.ps2pdf
/usr/bin/pdf2swf

system.antivir
/usr/bin/clamscan

application.url
http://188.4.72.198:8080/OpenKM/index.jsp



The last step: Logout OpenKM and restart tomcat server
# service tomcat7 restart