Installing OpenMercury on (Snow) Leopard
Server setup
First off, the requirements for OpenMercury are:
- java (J2SDK version 6) (included in OSX)
- Bash (included in OSX)
- Python (included in OSX, but we are going to install our own)
- GIT (from MacPorts)
- PostgreSQL (from MacPorts)
- Ant (from MacPorts)
- Apache Tomcat
So before we start we are going to need MacPorts. Download the DMG for your platform from the "Installing MacPorts"page.
Make sure you have Apple's Xcode Developer Tools installed (download at the Apple Developer Connection site or on you Mac OS X installation DVD). After installing Xcode, run the MacPorts Installer.
Add the following to your /etc/bashrc and open a new terminal to get access to the "port" command
export PATH="/opt/local/bin:/opt/local/lib/mysql5/bin:/opt/local/lib/postgresql84/bin:/opt/local/apache2/bin:$PATH"
Next, run the selfupdate command for MacPorts
sudo port -v selfupdate
sudo port -v selfupdate
After completion, install PostgreSQL, GIT and Apache Ant. Best get a cup of coffee at this point, it will take a while.
sudo port install postgresql84-server git-core apache-ant xorg-scrnsaverproto py26-psycopg2
Make sure your bash works with the MacPorts python by installing and running the following commands
sudo port install python_select sudo python_select python26
To start PostgreSQL at startup, execute the following command
sudo launchctl load -w /Library/LaunchDaemons/org.macports.postgresql84-server.plist
and create the database instance by executing:
sudo mkdir -p /opt/local/var/db/postgresql84/defaultdb sudo chown postgres:postgres /opt/local/var/db/postgresql84/defaultdb sudo su postgres -c '/opt/local/lib/postgresql84/bin/initdb -D /opt/local/var/db/postgresql84/defaultdb'
To improve basic PostgreSQL performance, edit or create /etc/sysctl.conf and add the following settings. You will need to reboot before this becomes active.
kern.sysv.shmmax=167772160 kern.sysv.shmmin=1 kern.sysv.shmmni=256 kern.sysv.shmseg=64 kern.sysv.shmall=65536
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 zip file. Extract the folder to a location of your choice. For the purpose of this guide we are going to place the folder in a folder in my home dir: ~/OpenMercury/tomcat
This is all there is: we have a working tomcat! We can now start it:
cd ~/OpenMercury/tomcat/bin ./catalina.sh jpda run
If you get an error saying you don't have permission to execute catalina.sh, change the persmissions from the finder or by running this command:
chmod -R 755 ~/OpenMercury/tomcat
Your console should fill with something like:
Using CATALINA_BASE: /Users/roderik/OpenMercury/tomcat Using CATALINA_HOME: /Users/roderik/OpenMercury/tomcat Using CATALINA_TMPDIR: /Users/roderik/OpenMercury/tomcat/temp Using JRE_HOME: /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home Using CLASSPATH: /Users/roderik/OpenMercury/tomcat/bin/bootstrap.jar Listening for transport dt_socket at address: 8000 Jan 27, 2010 2:04:52 PM org.apache.catalina.core.AprLifecycleListener init INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: .:/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java Jan 27, 2010 2:04:53 PM org.apache.coyote.http11.Http11Protocol init INFO: Initializing Coyote HTTP/1.1 on http-8080 Jan 27, 2010 2:04:53 PM org.apache.catalina.startup.Catalina load INFO: Initialization processed in 1094 ms Jan 27, 2010 2:04:53 PM org.apache.catalina.core.StandardService start INFO: Starting service Catalina Jan 27, 2010 2:04:53 PM org.apache.catalina.core.StandardEngine start INFO: Starting Servlet Engine: Apache Tomcat/6.0.24 Jan 27, 2010 2:04:53 PM org.apache.catalina.startup.HostConfig deployDirectory INFO: Deploying web application directory docs Jan 27, 2010 2:04:53 PM org.apache.catalina.startup.HostConfig deployDirectory INFO: Deploying web application directory examples Jan 27, 2010 2:04:54 PM org.apache.catalina.startup.HostConfig deployDirectory INFO: Deploying web application directory host-manager Jan 27, 2010 2:04:54 PM org.apache.catalina.startup.HostConfig deployDirectory INFO: Deploying web application directory manager Jan 27, 2010 2:04:54 PM org.apache.catalina.startup.HostConfig deployDirectory INFO: Deploying web application directory ROOT Jan 27, 2010 2:04:54 PM org.apache.coyote.http11.Http11Protocol start INFO: Starting Coyote HTTP/1.1 on http-8080 Jan 27, 2010 2:04:54 PM org.apache.jk.common.ChannelSocket init INFO: JK: ajp13 listening on /0.0.0.0:8009 Jan 27, 2010 2:04:54 PM org.apache.jk.server.JkMain start INFO: Jk running ID=0 time=0/39 config=null Jan 27, 2010 2:04:54 PM org.apache.catalina.startup.Catalina start INFO: Server startup in 1254 ms
As we can see, tomcat is now running. When we browse to http://localhost:8080/ we should be able to see the default website:
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:
mkdir ~/OpenMercury/source cd ~/OpenMercury/source 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=../../tomcat
We're now ready to comple the project:
ant compile
resulting in a log comparable to:
Buildfile: build.xml
prepare:
[mkdir] Created dir: /Users/roderik/OpenMercury/tomcat/webapps/ROOT
[mkdir] Created dir: /Users/roderik/OpenMercury/tomcat/webapps/ROOT/WEB-INF
[mkdir] Created dir: /Users/roderik/OpenMercury/tomcat/webapps/ROOT/WEB-INF/classes
[copy] Copying 7978 files to /Users/roderik/OpenMercury/tomcat/webapps/ROOT
tstamp:
compile:
[javac] Compiling 2459 source files to /Users/roderik/OpenMercury/tomcat/webapps/ROOT/WEB-INF/classes
...
[javac] Note: Some input files use or override a deprecated API.
[javac] Note: Recompile with -Xlint:deprecation for details.
[javac] 16 warnings
[copy] Copying 6 files to /Users/roderik/OpenMercury/tomcat/webapps/ROOT/WEB-INF/classes
BUILD SUCCESSFUL
Total time: 2 minutes 16 seconds
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 su postgres -c "psql -c \"create user testom with password 'testom';\"" sudo su postgres -c "psql -c \"create database testom with owner testom;\""
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 ~/OpenMercury/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 ~/OpenMercury/tmp/resized and ~/OpenMercury/tmp/upload
- A project name
To initialize the database:
cd ~/OpenMercury/
mkdir files
mkdir tmp
mkdir tmp/resized
mkdir tmp/upload
cd ~/OpenMercury/source/OpenMercury/docs/tools/newproject
bash installdb.sh -s localhost -f ~/OpenMercury/files \
-c ~/OpenMercury/tmp/upload \
-r ~/OpenMercury/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 ~/OpenMercury/source/OpenMercury/docs/tools/newproject
python genClasses.py --projectpath=${HOME}/OpenMercury/source/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 ~/OpenMercury/source/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 ~/OpenMercury/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)
After logging in, you will see a "please update" link on the bottom of the screen. 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.
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:
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:
- 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.
- 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.



