My Plone configuration

Basically this page is running on a - more or less - plain Plone 4 (currently 4.1.2 ). I just include some packages out of the collective.geo.*(search on pypi ) world, as well as my own plonetheme.sunburst based skin plonetheme.chrigl .

Because this is a really small page, I am only running a single Plone instance and there' s no need for a complex multi-instance-zeo-setup . Because there' s an already running apache2 on my server, I run my Plone behind it, using Zope's VirtualHostMonster .

Because my apache2 also serves home directories (e.g. ), my rewritings look like this:

RewriteCond %{REQUEST_URI} !^/~.*
RewriteCond %{REQUEST_URI} !^/icons/.*
RewriteCond %{REQUEST_URI} !^/build/.*
RewriteCond %{REQUEST_URI} !^/default-site/.*
RewriteCond %{REQUEST_URI} !^/error/.*
RewriteRule ^/(.*) http://localhost:8080/VirtualHostBase/http/%{SERVER_NAME}:80/Plone/VirtualHostRoot/$1 [L,P]

Since ^/~.*is user name, the other directories belong to apache2. It's necessary to pass these directories too, to find the folder, etc. images in apaches directory overview, as well as correct error handling.

Just for fun and testing, I'm running a varnish-3.0.1 cache in front of my instance (apache2 -> varnish -> Plone). With a proper configuration of varnish, it's possible to shut down the Plone instance, but still serve the page. However, at least as long as varnish cache the content. This is my varnish default.vcl

Plone is running on an Ubuntu 9.10 with upstart . So I decided to write two upstart scripts, one for the Plone instance and one for varnish.


# Plone - Web-Content Management System
# Based on Python and ZOPE

description "start chrigl's plone"
author "Christoph Glaubitz"
version "0.2"

console none
emits plone

start on (local-filesystems and net-device-up and runlevel [2345])
stop on runlevel [!2345]

exec /home/myuser/bin/plone-starter /home/myuser/Instances/chrigl/bin/instance console

[UPDATE]: Changed console to none, because of curios behavior of upstart.

Changed exec. Included plone-starter to emit the event plone. This triggers the start of plone-varnish. [/UPDATE]


# Varnish Cache
# an open source, state of the art web application accelerator.
# You install it on your web server and it makes your website fly.

description "start varnish for chrigl's plone"
author "Christoph Glaubitz"
version "0.2"

console none

start on plone
stop on runlevel [!2345]

# run varnish as user myuser
exec su -s /bin/sh -c 'exec "$0" "$@"' myuser -- /opt/varnish-3.0.2/sbin/varnishd -F -f /home/myuser/Instances/chrigl/varnish/default.vcl -s malloc,100M -T -a -n /home/chris/Instances/chrigl/var/varnish

[UPDATE]: Changed console to none because varnish was not able to bind to ports when using "console output"... do not know why!?

Changed the exec string: appended -n /home/chris/Instances/chrigl/var/varnish, to give varnish a working directory else than the global /opt/varnish-3.0.2/var

Changed to start on plone. The script plone-tester emits this upstart event. However, now varnish is just started when plone is running. No bad idea I think. [/UPDATE]

Because varnish does not have something like Plone's effective-user, it is a little bit tricky to start it as non-root. Also this version of upstart does not provide a solution for this problem. However, my solution is borrowed from here (thanks guys!).

With this scripts, it's very easy to control the daemons via initctl, e.g.:

# initctl start plone
# initctl start plone-varnish
# initctl status plone-varnish
plone-varnish start/running, process 19046

Update: I decided to install varnish not directly into my buildout, but system-wide. Also the default.vcl is handmade and resists outside buildout.