Productively running multiple versions of Alfresco

How do you juggle multiple versions of Alfresco on your local machine? At any given time, I’ve got at least three versions running: The latest Enterprise release, the Enterprise head, and the Community head. If one or more active Optaros clients aren’t yet on the latest release, those older releases are running as well.

There’s always more than one way to skin a cat but here’s how I handle this problem. First, I want to use a single Tomcat instance, but I don’t want all of my Alfresco versions running at the same time. Second, I want to use the same MySQL instance running with version-specific databases to keep them separate. Third, I want separate, version-specific data directories.

The solution is to name your databases and all of your version specific directories with a naming convention, and then use shell scripts to delete and create soft links in the appropriate locations that point to the version specific directories. (If you are running Windows you can do symbolic links too–they are called Junctions).

In an Alfresco install there are four directories that you need to address:

  • The data directory
  • The web application directory
  • The shared extension directory
  • The virtualization server directory

Decide on a naming convention. For my databases, I use alfrescoXXn where XX is the version number and n is the network abbreviation (“c” for community, “e” for enterprise, etc.). So my database for 2.2 Enterprise would be alfresco22e. For directories, I use alfresco-X.X-nnnn. So, for example, the directories for Alfresco 2.2 Enterprise would be:

  • /home/jpotts/alfresco/alfresco-2.2-enterprise/data
  • /home/jpotts/alfresco/alfresco-2.2-enterprise/webapp
  • /home/jpotts/alfresco/alfresco-2.2-enterprise/extension
  • /home/jpotts/alfresco/alfresco-2.2-enterprise/virtual

When I want to switch between versions, I just call a shell script with the version as the argument. It takes care of deleting the existing links and creating the new:

echo Switching to $1...
echo Switching webapp...
rm $TOMCAT_HOME/webapps/alfresco
ln -s /home/jpotts/alfresco/alfresco-$1/webapp $TOMCAT_HOME/webapps/alfresco
echo Switching extension directory...
rm $TOMCAT_HOME/shared/classes/alfresco/extension
ln -s /home/jpotts/alfresco/alfresco-$1/extension $TOMCAT_HOME/shared/classes/alfresco/extension
echo Clearing Tomcat work directory...
rm -rf $TOMCAT_HOME/work/Catalina/localhost/alfresco
echo Clearing Tomcat temp directory...
rm -rf $TOMCAT_HOME/temp/*
echo Switching virtual tomcat directory...
rm $VIRTUAL_TOMCAT_HOME
ln -s /home/jpotts/alfresco/alfresco-$1/virtual $VIRTUAL_TOMCAT_HOME

Note that in this set up, the data directory and the Alfresco database don’t have to be dealt with directly because they are referenced by the custom-repository.properties file residing in the version-specific extension directory.

While you’re at it, why not make it easier to clear out the repository? Set up a “clean” script that cleans out your data directory and then runs the db_remove and db_setup SQL scripts. Remember that you’ll either need version specific copies of these scripts or you’ll need to modify them to accept the version-specific database as an argument.

With this setup in place, you can set up new versions, switch between versions, and start over with a clean repo quickly and easily.

This entry was posted in Alfresco, Content Management and tagged . Bookmark the permalink.