Go to page content

Deployment

How to deploy Zotonic system

So you have built your Zotonic site, and now you want to show it to the world. This page tells you how to configure your zotonic environment so that it is ready for real-world website visitors.

As per the Installation Instructions, up until now you probably have always started Zotonic using the start.sh script. This is fine for debugging purposes, because it gives you an Erlang shell in which you can view the output of the server, the ?DEBUG messages that are triggered, and try out Erlang expressions.

However for a production system, you don't need this shell, you want Zotonic running in the background. Meet zotonic.sh!

##
## usage zotonic.sh {debug|start|stop|restart}
##
## Use "debug" to start an interactive shell (highly recommended when installing the db on the first run).
## Use "start" in production. This boots zotonic in an erlang vm with a heart beat process.
##
## The proposed directory structure is:
## /home/zotonic/zotonic.sh                         -- this script
## /home/zotonic/zotonic/...                        -- the zotonic code
## /home/zotonic/zotonic/priv/sites/default/...     -- your site and uploaded files go here

Copy the file zotonic.sh from the doc/ directory in the Zotonic repository, to a place somewhere on your filesystem, for instance to /home/zotonic/zotonic.sh like suggested.

Now, you need to alter a few variables to suit your environment. I'm only listing a few critical variables here, the zotonic.sh file is pretty self-documenting.

  • BASE - Change this to your base directory (e.g. /home/zotonic)
  • ZOTONIC_IP - What IP address to listen on (the default, 'any' is fine)
  • ZOTONIC_PORT - What port to listen on
  • ERL - Where does your erlang installation live.

Now, you can start zotonic in the background:

/home/zotonic/zotonic.sh start

It's as easy as that! Now let's continue with putting a proxying webserver in front of Zotonic.

Using Varnish as frontend for Zotonic

Using the Varnish HTTP frontend, you can speed up your Zotonic even more as this web server caches static files intelligently.

Excerpt from config.vlc, configuring a Varnish backend for Zotonic:

backend zotonic_default {
  .host = "127.0.0.1";
  .port = "8000";
  .first_byte_timeout = 300s;
  .connect_timeout = 300s;
  .between_bytes_timeout = 300s;
}

Excerpt from config.vlc, redirecting a host to the Zotonic backend:

if (req.http.host ~ "^(www.|)zotonic.(com|net)$") {
    set req.backend   = zotonic_default;
}

This page is part of the Zotonic documentation, which is licensed under the Apache License 2.0.