+1 571-297-6383 | info@sonjara.com

Managing multiple Fakoli applications on a single server

Often we want to run multiple Fakoli instances on the same server. The most common reason for this is maintaining our development and staging servers - we don't want to go through the time or expense of setting up a new development server every time we start a new project. The second scenario is simply to save hosting costs. Fakoli is efficient with resources, so why have more servers than you need? If your sites are not in constant use, or have relatively low traffic, consolidating them onto one server makes sense.

Of course, sharing a server can lead to configuration issues. What happens if you make a change to one of your applications that relies on a newer version of Fakoli that would (potentially) break your other applications on that same server? And how do we make sure that all the schema changes are applied consistently when the underlying libraries are updated? Well, here is a collection of three bash scripts that can help with both these problems.

Scenario 1 - Single shared Fakoli Version

This is the simpler deployment scenario, suitable for development servers. In this scheme, we have the trunk branch of Fakoli checked out via SVN and used for all the applications on the server. This is the usual installation as described in the installation guide:

cd /srv/www/phplibs
svn co https://svn.code.sf.net/p/fakoli/code/trunk fakoli

To keep all the applications up-to-date, we need to make sure that their component scans are run whenever the Fakoli code is updated (to pick up any schema changes that might otherwise cause errors). We do this with the following script:


echo "---------Updating Fakoli------------"

cd /srv/www/phplibs/fakoli
svn up

for site in "$@"
  echo "---------Updating $site------------"
  cd /srv/www/vhosts/$site
  svn up

for i in `ls /srv/www/vhosts/`
  if [ -f /srv/www/vhosts/$i/page.php ]
    echo "*** Scanning $i"
    wget -t 1 -q -O - http://$i/action/component/scan;

Put this script in /usr/local/bin and make it executable. Its usage is simple, and combines updating the Fakoli library with updating your application code (this helps make sure everything is in sync during development). To update your latest commits to awesome.fakoli.org you would run the command:

fakoli_update awesome.fakoli.org

This then updates both Fakoli and your application to their latest and greatest, and runs component scans on all the Fakoli applications in your vhosts directory to make sure they are in sync. If there are any compatibility issues you will be able to see the errors reported to your terminal.

Scenario 2 - Multiple Fakoli Versions on the Same Server

For a server hosting multiple live applications the best practice is to ensure that each application is running a version of Fakoli that it has been fully tested with. Fortunately it is fairly simple to set up a deployment scheme to make this easy to manage. Here are the two scripts we will need:


This scripts checks out a tagged Fakoli point release into a versioned subdirectory under /srv/www/phplibs/fakoli/

echo "---------Checking out Fakoli version $1------------"

cd /srv/www/phplibs/fakoli
svn co https://svn.code.sf.net/p/fakoli/code/tags/$1 $1


This script updates a given list of sites to a specified Fakoli version.



echo "Checking for Fakoli $version"


if [ ! -d /srv/www/phplibs/fakoli/$version ];
        fakoli_checkout $version;

while (( "$#" )); do

        echo "---------Upgrading $1 to Fakoli $version------------"

        if [ -L /srv/www/phplibs/fakoli/$1 ];
                rm /srv/www/phplibs/fakoli/$1;

        ln -s /srv/www/phplibs/fakoli/$version /srv/www/phplibs/fakoli/$1;

        echo "*** Scanning $1"
        wget -t 1 -q -O - http://$1/action/component/scan;



To make use of these scripts we need to configure each of our applications to use a PHP include_path specific to that application. To do this just edit (or create) the .htaccess file in the application's root directory, and add the following line:

php_value include_path ".:/srv/www/phplibs/fakoli/<site>:/srv/www/phplibs"

Where <site> is the name of the application (i.e. awesome.fakoli.org

So, if we have two applications on our server, awesome.fakoli.org and bodacious.fakoli.org, we can set them to use version 3.2.0 of Fakoli by running this command:

fakoli_version 3.2.0 awesome.fakoli.org bodacious.fakoli.org

Now if we want to upgrade awesome.fakoli.org to use Fakoli 3.2.8 while leaving bodacious.fakoli.org on version 3.2.0 we would just run the command:

fakoli_version 3.2.8 awesome.fakoli.org

Finishing up

Hopefully these scripts will be useful in helping with your Fakoli version control. I have packaged them up in a handy ZIP file, which you can download here.

By Andy Green, posted on Thursday April 4, 2013


* indicates required field