# Global configuration

Source: https://zotonic.com/docs/1454/global-configuration

URI: https://zotonic.com/id/1454

Language: en



<div>
            
  <div class="section">

<p>This section describes the location and contents of Zotonic’s global
configuration files <code class="docutils literal notranslate"><span class="pre">erlang.config</span></code> and <code class="docutils literal notranslate"><span class="pre">zotonic.config</span></code>. There’s also
<a class="reference internal" href="/id/doc_developerguide_configuration_site_configuration#ref-site-configuration"><span class="std std-ref">site-specific configuration</span></a>.</p>
<div class="section">
<h2>Config file locations</h2>
<p>Zotonic depends on two global config files, called <code class="docutils literal notranslate"><span class="pre">zotonic.config</span></code>
and <code class="docutils literal notranslate"><span class="pre">erlang.config</span></code>. On startup, Zotonic looks in the following
places for these files:</p>

<p><ul class="simple">
<li>The init argument <code class="docutils literal notranslate"><span class="pre">zotonic_config_dir</span></code></li>
<li>The environment variable <code class="docutils literal notranslate"><span class="pre">ZOTONIC_CONFIG_DIR</span></code></li>
<li>The directory <code class="file docutils literal notranslate"><span class="pre">$HOME/.zotonic</span></code></li>
<li>The directory <code class="file docutils literal notranslate"><span class="pre">/etc/zotonic</span></code> (only on Unix)</li>
<li>The OS specific directory for application config files</li>
</ul>
</p>
<p>The OS specific directories are:</p>

<p><ul class="simple">
<li>On Unix: <code class="file docutils literal notranslate"><span class="pre">~/.config/zotonic/config/</span></code></li>
<li>On macOS: <code class="file docutils literal notranslate"><span class="pre">~/Library/Application</span> <span class="pre">Support/zotonic/config/</span></code></li>
</ul>
</p>
<p>In those directories the system searches for a <code class="docutils literal notranslate"><span class="pre">zotonic*</span></code> file in the following subdirectories (assuming the version of Zotonic is 1.2.3 and the node is called <code class="docutils literal notranslate"><span class="pre">zotonic001@foobar</span></code>):</p>

<p><ul class="simple">
<li><code class="docutils literal notranslate"><span class="pre">zotonic001@foobar/</span></code></li>
<li><code class="docutils literal notranslate"><span class="pre">zotonic001/</span></code></li>
<li><code class="docutils literal notranslate"><span class="pre">1.2.3/</span></code></li>
<li><code class="docutils literal notranslate"><span class="pre">1.2/</span></code></li>
<li><code class="docutils literal notranslate"><span class="pre">1/</span></code></li>
<li><code class="docutils literal notranslate"><span class="pre">.</span></code></li>
</ul>
</p>
<p>The default is the OS specific directory, with as subdirectory the major version number of Zotonic (in this case <code class="docutils literal notranslate"><span class="pre">1</span></code>).
For Linux this would be <code class="file docutils literal notranslate"><span class="pre">~/.config/zotonic/config/1/</span></code></p>
<p>The nodename is the name of the Zotonic Erlang node, which
defaults to <code class="docutils literal notranslate"><span class="pre">zotonic001</span></code> (and can be set with <code class="docutils literal notranslate"><span class="pre">$SNAME</span></code> or <code class="docutils literal notranslate"><span class="pre">$LNAME</span></code>
environment variable). Using the node name in the configuration path comes in
handy when you want to run multiple Zotonic instances simultaneously.</p>
<p>By checking for <em>version</em> you can have separate configuration files for different versions of Zotonic
which are running simultaneously.</p>
<p>If the Zotonic startup script finds a <code class="docutils literal notranslate"><span class="pre">zotonic*</span></code> file in one of the
directories, it stops looking, so files in the other directories are
ignored.</p>
<p>Zotonic will also load all configuration files in the <code class="docutils literal notranslate"><span class="pre">config.d</span></code> directory inside the Zotonic directory.</p>
<p>In the course of Zotonic starting up, it will print the locations of
the global config files that it is using:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>12:42:17.351 [info] zotonic_launcher_sup:36 ================
12:42:17.351 [info] zotonic_launcher_sup:37 Zotonic starting
12:42:17.351 [info] zotonic_launcher_sup:38 ================
12:42:17.351 [info] zotonic_launcher_sup:39 Init files used:
12:42:17.356 [info] zotonic_launcher_sup:40 - /home/user/.config/zotonic/config/1/erlang.config
12:42:17.356 [info] zotonic_launcher_sup:41 Config files used:
12:42:17.357 [info] zotonic_launcher_sup:43 - /home/user/.config/zotonic/config/1/zotonic.config
12:42:17.357 [info] zotonic_launcher_sup:44 ================
</pre></div>
</div>
<p>The used configuration files can be listed with <code class="docutils literal notranslate"><span class="pre">bin/zotonic</span> <span class="pre">configfiles</span></code>:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>user$ bin/zotonic configfiles
Zotonic config files for zotonic001@foobar:
- /home/user/.config/zotonic/config/1.0/erlang.config
- /home/user/.config/zotonic/config/1.0/zotonic.config
</pre></div>
</div>
</div>
<div class="section">
<h2>The <code class="docutils literal notranslate"><span class="pre">zotonic.config</span></code> file</h2>
<p>After installed for the first time, the <code class="docutils literal notranslate"><span class="pre">~/.zotonic/1/zotonic.config</span></code> file is well
annotated with comments about what each setting does. When in doubt, consult the
stock <code class="docutils literal notranslate"><span class="pre">apps/zotonic_launcher/priv/config/zotonic.config.in</span></code> file for explanation
about all config settings.</p>
<p>In the <code class="docutils literal notranslate"><span class="pre">zotonic.config</span></code> file you will find the password for the
<code class="docutils literal notranslate"><span class="pre">zotonic_status</span></code> site where you can manage the server.</p>
<p>Zotonic configurations can also be fetched in the Erlang shell.
For example, view the <code class="docutils literal notranslate"><span class="pre">zotonic_status</span></code> password:</p>
<div class="highlight-erlang notranslate"><div class="highlight"><pre><span></span><span class="nn">z_config</span><span class="p">:</span><span class="nb">get</span><span class="p">(</span><span class="n">password</span><span class="p">).</span>
</pre></div>
</div>
<p>The Zotonic configuration files are read by the <code class="docutils literal notranslate"><span class="pre">zotonic_launcher</span></code> application before
starting the core zotonic applications and all sites.</p>
<p>The zotonic configuration van be viewed with <code class="docutils literal notranslate"><span class="pre">bin/zotonic</span> <span class="pre">config</span></code>:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>Zotonic config for zotonic001@aloha:
====================================

zotonic:
    environment: production
    zotonic_apps: /home/user/zotonic/apps_user
    security_dir: /home/user/.config/zotonic/security
    password: Bthj3ruGbmgJxfmc
    timezone: UTC
    listen_ip: any
    listen_ip6: any
    listen_port: 8000
    ssl_listen_port: 8443
    port: 80
    ssl_port: 443
    max_connections: 20000
    ...
</pre></div>
</div>
</div>
<div class="section">
<a name="erlang-config"></a><h2>The <cite>erlang.config</cite> file</h2>
<p>The <code class="docutils literal notranslate"><span class="pre">erlang.config</span></code> file contains application environment variables
for the Erlang applications that Zotonic depends on. Here you can
configure for instance the paths for the <a class="reference internal" href="/id/doc_developerguide_testing#dev-testing"><span class="std std-ref">log files</span></a> (in
the <code class="docutils literal notranslate"><span class="pre">kernel</span></code> section), emqtt ports, et cetera.</p>
<p>This file is included as an <em>init</em> configuration option when starting <code class="docutils literal notranslate"><span class="pre">erl</span></code>
via the command line script in <code class="docutils literal notranslate"><span class="pre">bin/zotonic</span></code>.</p>
<p>The erlang configuration van be viewed with <code class="docutils literal notranslate"><span class="pre">bin/zotonic</span> <span class="pre">config</span> <span class="pre">erlang</span></code>:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>Erlang init for zotonic001@aloha:
=================================

exometer:
    predefined:
      - {[erlang,memory],{function,erlang,memory,[],value,[]},[]}
      - {[erlang,system_info],
         {function,erlang,system_info,['$dp'],value,[process_count]},
         []}
      - {[erlang,statistics],
         {function,erlang,statistics,['$dp'],value,[run_queue]},
         []}
      - {[erlang,io],
         {function,erlang,statistics,[io],match,{{'_',input},{'_',output}}},
         []}
filezcache:
    data_dir: priv/filezcache/data
    journal_dir: priv/filezcache/journal
kernel:
...
</pre></div>
</div>
</div>
</div>


           </div>

License: 

Attribution: 

Related resources: https://zotonic.com/api/agent/related/1454?language=en


## API access

- [API help](<https://zotonic.com/api-help>)
- [OpenAPI specification](<https://zotonic.com/openapi.json>)
- [This resource as JSON](<https://zotonic.com/api/agent/resource/1454?language=en>)
