<!doctype html><htmllang=en-us><head><metacharset=utf-8><metahttp-equiv=x-ua-compatiblecontent="ie=edge"><metaname=viewportcontent="width=device-width,initial-scale=1,shrink-to-fit=no"><linkrel=preloadas=fonthref=/fonts/vendor/jost/jost-v4-latin-regular.woff2type=font/woff2crossorigin><linkrel=preloadas=fonthref=/fonts/vendor/jost/jost-v4-latin-700.woff2type=font/woff2crossorigin><linkrel=stylesheethref=/main.d731b24f97a905b851b9151339aca0f6a9b1c45ed16584cee7a4113d98d2a3db570c096603fbf15fbe9bbf092715cc742abaea351b4767239dbfedfffc08ebdb.cssintegrity="sha512-1zGyT5epBbhRuRUTOayg9qmxxF7RZYTO56QRPZjSo9tXDAlmA/vxX76bvwknFcx0KrrqNRtHZyOdv+3//Ajr2w=="crossorigin=anonymous><noscript><style>img.lazyload{display:none}</style></noscript><metaname=robotscontent="index, follow"><metaname=googlebotcontent="index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1"><metaname=bingbotcontent="index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1"><title>Databse and cache - mCaptcha</title><metaname=descriptioncontent="mCaptcha server requires dependencies like a Postgres database and a Redis cache"><linkrel=canonicalhref=/docs/self-hosted/dependencies/><metaname=twitter:cardcontent="summary_large_image"><metaname=twitter:imagecontent="/icon.png"><metaname=twitter:titlecontent="Databse and cache"><metaname=twitter:descriptioncontent="mCaptcha server requires dependencies like a Postgres database and a Redis cache"><metaname=twitter:sitecontent="@"><metaname=twitter:creatorcontent="@"><metaproperty="og:title"content="Databse and cache"><metaproperty="og:description"content="mCaptcha server requires dependencies like a Postgres database and a Redis cache"><metaproperty="og:type"content="article"><metaproperty="og:url"content="/docs/self-hosted/dependencies/"><metaproperty="og:image"content="/icon.png"><metaproperty="article:modified_time"content="2021-07-21T15:49:53+05:30"><metaproperty="og:site_name"content="mCaptcha"><metaproperty="article:publisher"content="https://www.facebook.com/"><metaproperty="article:author"content="https://www.facebook.com/"><metaproperty="og:locale"content="en_US"><scripttype=application/ld+json>{"@context":"http://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"\/"},{"@type":"ListItem","position":2,"name":"Docsself Hosteddependencies","item":"\/docsself-hosteddependencies\/"}]}</script><metaname=theme-colorcontent="#fff"><linkrel=apple-touch-iconsizes=180x180href=/apple-touch-icon.png><linkrel=icontype=image/pngsizes=32x32href=/favicon-32x32.png><linkrel=icontype=image/pngsizes=16x16href=/favicon-16x16.png><linkrel=manifesthref=/site.webmanifest></head><bodyclass="docs single"><divclass="header-bar fixed-top"></div><headerclass="navbar fixed-top navbar-expand-md navbar-light"><divclass=container><inputclass="menu-btn order-0"type=checkboxid=menu-btn>
library which checks SQL queries at compile time. So if you are starting
with a fresh database without migrations applied, compilation will fail.</p></li></ul><h3id=redis>Redis<ahref=#redisclass=anchoraria-hidden=true>#</a></h3><ul><li><p>Redis is an optional dependency. Currently, the non-Redis configuration
doesn’t persist CAPTCHA heat. So if there’s a systems failure, CAPTCHA
heat will be reset and visitor count will start from 0. For small
installations, this should post a problem as heat is short lived and is
reset anyways at cool down period.</p></li><li><p>mCaptcha uses a custom Redis module called
<ahref=https://github.com/mCaptcha/cache>cache</a> to overcome some of Redis'
limitations.</p></li></ul><h2id=instructions>Instructions<ahref=#instructionsclass=anchoraria-hidden=true>#</a></h2><p>Once again, there are two ways to go about this:</p><ol><li>Docker</li><li>Bare metal</li></ol><h3id=docker>Docker<ahref=#dockerclass=anchoraria-hidden=true>#</a></h3><h3id=database-1>Database<ahref=#database-1class=anchoraria-hidden=true>#</a></h3><p>Download and run Postgres</p><divclass=highlight><preclass=chroma><codeclass=language-bashdata-lang=bash>docker create --name mcaptcha-postgres <spanclass=se>\
</code></pre></div><p>See <ahref=https://github.com/mCaptcha/cache>mCaptcha/cache</a> for more
details.</p><h3id=1-install-postgres-if-you-dont-have-it-already>1. Install Postgres if you don’t have it already.<ahref=#1-install-postgres-if-you-dont-have-it-alreadyclass=anchoraria-hidden=true>#</a></h3><p>For Debian based distributions:</p><divclass=highlight><preclass=chroma><codeclass=language-bashdata-lang=bash>sudo apt install postgres
</code></pre></div><h3id=2-create-new-user-for-running-mcaptcha>2. Create new user for running <code>mCaptcha</code><ahref=#2-create-new-user-for-running-mcaptchaclass=anchoraria-hidden=true>#</a></h3><divclass=highlight><preclass=chroma><codeclass=language-bashdata-lang=bash>$ sudo useradd -b /srv -m -s /usr/bin/bash mcaptcha
</code></pre></div><h3id=3-create-new-user-in-postgres>3. Create new user in Postgres<ahref=#3-create-new-user-in-postgresclass=anchoraria-hidden=true>#</a></h3><divclass=highlight><preclass=chroma><codeclass=language-bashdata-lang=bash>$ sudo -iu postgres <spanclass=c1># switch to `postgres` user</span>
$ psql
<spanclass=nv>postgres</span><spanclass=o>=</span><spanclass=c1># CREATE USER mcaptcha WITH PASSWORD 'my super long password and yes you need single quote';</span>
$ createdb -O mcaptcha mcaptcha <spanclass=c1># create db 'mcaptcha' with 'mcaptcha' as owner</span>
</code></pre></div><h3id=4-install-mcaptchacachehttpsgithubcommcaptchacache>4. Install <ahref=https://github.com/mCaptcha/cache><code>mCaptcha/cache</code></a><ahref=#4-install-mcaptchacachehttpsgithubcommcaptchacacheclass=anchoraria-hidden=true>#</a></h3><p>See <ahref=https://github.com/mCaptcha/cache><code>mCaptcha/cache</code></a> for more
details.</p><pclass=edit-page><ahref=https://github.com/mCaptcha/website/blob/master/content/docs/self-hosted/dependencies.md><svgxmlns="http://www.w3.org/2000/svg"width="16"height="16"viewBox="0 0 24 24"fill="none"stroke="currentcolor"stroke-width="2"stroke-linecap="round"stroke-linejoin="round"class="feather feather-edit-2"><pathd="M17 3a2.828 2.828.0 114 4L7.5 20.5 2 22l1.5-5.5L17 3z"/></svg>Edit this page on GitHub</a></p><divclass="docs-navigation d-flex justify-content-between"><ahref=/docs/api/pow-sha256/><divclass="card my-1"><divclass="card-body py-2">← pow_sha256</div></div></a><aclass=ms-autohref=/docs/help/troubleshooting/><divclass="card my-1"><divclass="card-body py-2">Troubleshooting →</div></div></a></div></main></div></div></div><footerclass="footer text-muted"><divclass=container><divclass=row><divclass="col-lg-8 order-last order-lg-first"><ulclass=list-inline><liclass=list-inline-item>Powered by <ahref=https://gohugo.io/>Hugo</a>, and <ahref=https://getdoks.org/>Doks</a></li></ul></div><divclass="col-lg-8 order-first order-lg-last text-lg-end"><ulclass=list-inline><liclass=list-inline-item><ahref=/about/>About</a></li><liclass=list-inline-item><ahref=/donate>Donate</a></li><liclass=list-inline-item><ahref=/privacy-policy/>Privacy</a></li><liclass=list-inline-item><ahref=/security>Security</a></li><liclass=list-inline-item><ahref=https://stats.uptimerobot.com/GK7VLFJnBl>Status</a></li><liclass=list-inline-item><ahref=/thanks>Thanks</a></li></ul></div></div></div></footer><scriptsrc=/main.min.db67f0caa6a5788b691b9509981d6e5943f4b8d829170a674f468d4b23671ce4017c47a0a22116a8fc2f2de556c8b48f1afecd86707066f2f022c5dd83e8ea3c.jsintegrity="sha512-22fwyqaleItpG5UJmB1uWUP0uNgpFwpnT0aNSyNnHOQBfEegoiEWqPwvLeVWyLSPGv7NhnBwZvLwIsXdg+jqPA=="crossorigin=anonymousdefer></script><scriptsrc=/index.min.aab62a01bb69c52990d1e9a9072a01da2b9367f1a41ff3fa2b71ccdec4240b589f7196886485c3dd15f0598e76f83630d9f9432840f1758143eb96b263dcbe1e.jsintegrity="sha512-qrYqAbtpxSmQ0empByoB2iuTZ/GkH/P6K3HM3sQkC1ifcZaIZIXD3RXwWY52+DYw2flDKEDxdYFD65ayY9y+Hg=="crossorigin=anonymousdefer></script></body></html>