Installing OpenMercury on Linux

This guide will show how to install OpenMercury on a linux system. It assumes linux knowledge: you need to be able to use a terminal, and you need to understand the commands a bit. I assume you install everything under your homedir, ${HOME}.
The instructions below will also work on MacOS X.

Requirements

You will need the following to be able to follow this document:

  • Linux
  • PostgreSQL
  • git
  • java (J2SDK version 6)
  • ant
  • python and bash (normally they are preinstalled on linux and MacosX systems)

Tomcat installation

We will do a minimal tomcat install for this example. Doing a minimal install (without apache integration) is quite simple: we just need to untar/unzip our download and we're ready to go. To do this, go to http://tomcat.apache.org/download-60.cgi and download the core tar.gz.

We need to untar it somewhere, let's say under ${HOME}/om/:

cd ${HOME}/om/
tar -zxf ${HOME}/Downloads/tomcat-6.0.20.tar.

After doing this, a folder apache-tomcat-6.0.20 should appear. Let's rename it to "tomcat" so we don't have to type the version number over and over again:

mv apache-tomcat-6.0.20 tomcat

This is all there is: we have a working tomcat! We can now start it: 

cd tomcat/default/bin
./catalina.sh jpda run

We use catalina.sh instead of startup.sh: this allows us to specify we want to be able to debug (jpda) and we don't want to start it in the background as a daemon, so we see all log messages scrolling by immediately (run).

The output should be something like this:  

Using CATALINA_BASE:   /home/kervel/tmp/om/tomcat
Using CATALINA_HOME:   /home/kervel/tmp/om/tomcat
Using CATALINA_TMPDIR: /home/kervel/tmp/om/tomcat/temp
Using JRE_HOME:       /usr
Dec 15, 2009 4:47:01 PM org.apache.catalina.core.AprLifecycleListener init
Dec 15, 2009 4:47:01 PM org.apache.coyote.http11.Http11Protocol init
INFO: Initializing Coyote HTTP/1.1 on http-8080
Dec 15, 2009 4:47:01 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 995 ms
Dec 15, 2009 4:47:01 PM org.apache.catalina.core.StandardService start
INFO: Starting service Catalina
Dec 15, 2009 4:47:01 PM org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/6.0.20
Dec 15, 2009 4:47:02 PM org.apache.coyote.http11.Http11Protocol start
INFO: Starting Coyote HTTP/1.1 on http-8080
Dec 15, 2009 4:47:02 PM org.apache.jk.common.ChannelSocket init
INFO: JK: ajp13 listening on /0.0.0.0:8009
Dec 15, 2009 4:47:02 PM org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=0/18  config=null
Dec 15, 2009 4:47:02 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 1388 ms

As we see catalina's now running. When we surf to http://localhost:8080/ we should be able to see the default website:

Tomcat default startup page Tomcat default startup page

Getting the source and setting up ant

Now we're ready to get the source from github. Stop the tomcat server for now (control-C will stop it) and download openmercury using git:

cd ${HOME}/om
git clone git://github.com/smartlounge/OpenMercury.git

When this command completes (it shouldn't take too long) you should have an OpenMercury folder. In this folder, you should have everything to start compiling. We will setup our compilation so that the compiled classes go directly into the tomcat webapps folder. We need to change one line in build.properties, so that ant knows where our tomcat server is. (ant needs this info to put the compiled classes in the right place). 

catalina.home=${HOME}/om/tomcat

 We're now ready to comple the project:

ant compile

Don't start tomcat yet, we need a database first! 

Creating a database

First, we need to create an empty postgreSQL database and a user that can access this database.  We normally use the database on the same machine as the application server. This is not strictly needed, but we found out that it is more performant to run both on the same server.
Let's call the database testom. If we do everything on the command line, we first need to connect to postgresql in administrator mode:

sudo -i
su - postgres
psql

Then we need to create the user and the database: 

postgres=# create user testom with password 'testom';
CREATE ROLE
postgres=# create database testom with owner testom;
CREATE DATABASE
postgres=# \q

 

Now it is time to initialize the database. This step will create a lot of tables, put some initial data and do some configuration. OpenMercury needs several folders to work:

  • A filestore: this is where digital assets (files , images , ...) will be stored. It should be a location that is included in your backup scheme if you deploy on a production server. The folders must exist and be writable. Let's take ${HOME}/om/files
  • A "uploadcache" and "resizedcache": first one is a temporary place for uploaded cache, the second one contains generated thumbnails for images. No need to backup this folder: when the thumbnails are gone, the CMS will regenerate them. The folders must exist and be writable. Lets take ${HOME}/om/tmp/resized and ${HOME}/om/tmp/upload
  • A project name

To initialize the database: 

 

cd ${HOME}/om
mkdir files
mkdir tmp
mkdir tmp/resized
mkdir tmp/upload
cd ${HOME}/om/OpenMercury/docs/tools/newproject
bash installdb.sh -s localhost -f ${HOME}/om/files \
      -c ${HOME}/om/tmp/upload \
      -r ${HOME}/om/tmp/resized \
      -u testom -p testom -d testom \
      -n OpenMercuryTest

This will fill  the database with inital content and also generate a sml_database.xml file under WebRoot/WEB-INF/. This file contains the database username and password, and openmercury uses it to connect to the database. 

Generating a basic website

Now the CMS is actually already ready to run. But we're going to create a basic website first. We will generate java and velocity code that is enough for a basic website. The generated code can be changed by hand later.

cd ${HOME}/om/OpenMercury/docs/tools/newproject
python genClasses.py --projectpath=${HOME}/om/OpenMercury/ testsite

this will generate classes in be.smartlounge.testsite like TestsiteWebsite and so on. 

Running it!

Ok, now we are completely done. let's compile the code once more:

cd ${HOME}/om/OpenMercury
ant compile

and we're ready to start our tomcat again (if you didn't stop it, you need to stop it first): 

cd ${HOME}/om/tomcat/bin
./catalina.sh jpda run

When it starting up you should see the following scrolling by: 

OpenMercury Starting ...
Loading type register...
Parsing SML Config...
Setting ServiceCatalog...
Getting fresh entity ID...
Loading configuration entity...
Initializing caches...
Startup completed

This can take a while, especially the first time you start openmercury. After you see "startup completed" the CMS is ready to use. Let's go to the admin page on http://localhost:8080/edit/en (you will need to log in with the default username and password admin / admin) 

The admin interface The admin interface

On the bottom of the screen you see a "please update" link. Click on it! The updater will remain busy for a while and do things like:

  • making sure the database is up-to-date with the code
  • installing the "creator". this creator will deploy objects of our generated classes.

After the updater completes go back to the CMS (make sure you refresh the page if you use the browsers back button). You should find "Testsite creator part" under settings.

Creating the basic website Creating the basic website

There, click the "create" button. It should start creating a website immediately. This website doesn't contain much interesting yet. Let's create a full set of example pages, blog posts, comments, a calendar, and so on. To do this, we need to find another creator inside the website:

Filling the basic website Filling the basic website

You will find this creator under Home - Default website - Settings - Website Feature Creator

Here you have a lot of possiblities. Goal is to be able to fill the website with examples, complete the styling / templating and then clean up the examples to do the final content fill. One of the links should read "you can also create the reference project". click it. It will create everything, fill all pages with dummy lorem ipsum text, and download some random images from Flickr to have images here and there.

The website should be accessible under http://localhost:8080/nl

There are still two caveats here:

  1. Before you can start editing pages in the CMS you need to logout and login again. This is because the creator changes the permissions, and you need to refresh the permissions.
  2. The website is now only published in the dutch (nl) language. If you want other languages, you need to publish yourself. We hope to fix this in the next release.

Download

Download or fork the source code for OpenMercury from

Download

Download or fork us on GitHub