Search code examples
phpfilesystemshostingmatomocloudcontrol

Hosting piwik on a server with a read-only filesystem


I use CloudControl for hosting and I would like to set up a server (possibly with load balancing support) to host piwik for all of my websites. The only problem is that the only writable directory CloudControlled allows you to access is defined by $_SERVER['TMPDIR'].

Is it possible to modify piwik to use this directory for all of its file-writing needs?

And also will I run into any issues with using load balancing? Something like automatically generated reports being generated by each node behind my load balancer since they're not aware of each other?


Solution

  • The idea is to keep this change for your system even when you update.

    This is easy to do: create a bootstrap.php inside the piwik main folder.

    This is the content of said file:

    <?php
    define('PIWIK_USER_PATH', $_SERVER['TMPDIR']);
    

    You can double-check this: in index.php, you should see that it checks for a bootstrap.php file in the same folder. It's included when available, and this allows you to do little customizations and keep them even when you update. E.g. I've run piwik from svn for the past three years or so and have some custom changes in there.