<!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.c5ebec6f69f6fedddbd813e6fbeec336e7050cd17bb6fef39275d0956f6115409a7083647b41bca8cc86d5c0a35d49b0692a89702d12c76f9b8d315ea33c0b87.cssintegrity="sha512-xevsb2n2/t3b2BPm++7DNucFDNF7tv7zknXQlW9hFUCacINke0G8qMyG1cCjXUmwaSqJcC0Sx2+bjTFeozwLhw=="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>Database and cache - mCaptcha</title><metaname=descriptioncontent="mCaptcha server requires dependencies like a Postgres database and a Redis cache"><linkrel=canonicalhref=/docs/self-hosting/dependencies/><metaname=twitter:cardcontent="summary_large_image"><metaname=twitter:imagecontent="/icon.png"><metaname=twitter:titlecontent="Database 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="Database 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-hosting/dependencies/"><metaproperty="og:image"content="/icon.png"><metaproperty="article:modified_time"content="2023-10-27T21:39:40+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 Hostingdependencies","item":"\/docsself-hostingdependencies\/"}]}</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>
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
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><prestyle=color:#f8f8f2;background-color:#282a36;-moz-tab-size:4;-o-tab-size:4;tab-size:4><codeclass=language-bashdata-lang=bash><spanstyle="margin-right:.4em;padding:0 .4em;color:#7f7f7f">1</span>docker create --name mcaptcha-postgres <spanstyle=color:#f1fa8c>\
</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><prestyle=color:#f8f8f2;background-color:#282a36;-moz-tab-size:4;-o-tab-size:4;tab-size:4><codeclass=language-bashdata-lang=bash><spanstyle="margin-right:.4em;padding:0 .4em;color:#7f7f7f">1</span>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><prestyle=color:#f8f8f2;background-color:#282a36;-moz-tab-size:4;-o-tab-size:4;tab-size:4><codeclass=language-bashdata-lang=bash><spanstyle="margin-right:.4em;padding:0 .4em;color:#7f7f7f">1</span>$ 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><prestyle=color:#f8f8f2;background-color:#282a36;-moz-tab-size:4;-o-tab-size:4;tab-size:4><codeclass=language-bashdata-lang=bash><spanstyle="margin-right:.4em;padding:0 .4em;color:#7f7f7f">1</span>$ sudo -iu postgres <spanstyle=color:#6272a4># switch to `postgres` user</span>
<spanstyle="margin-right:.4em;padding:0 .4em;color:#7f7f7f">3</span><spanstyle=color:#8be9fd;font-style:italic>postgres</span><spanstyle=color:#ff79c6>=</span><spanstyle=color:#6272a4># CREATE USER mcaptcha WITH PASSWORD 'my super long password and yes you need single quote';</span>
<spanstyle="margin-right:.4em;padding:0 .4em;color:#7f7f7f">4</span>$ createdb -O mcaptcha mcaptcha <spanstyle=color:#6272a4># 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://git.batsense.net/mCaptcha/website/blob/master/content/docs/self-hosting/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 git.batsense.net</a></p><divclass="docs-navigation d-flex justify-content-between"><ahref=/docs/self-hosting/docker/><divclass="card my-1"><divclass="card-body py-2">← Using Docker</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.993b2b4c58b07e7a4bb3423cf18ccd78a85d0063680c0fc9bf6d9cc02be98e08793034d984dd8f7c60ad5b70f3186cc8bc280b1077b7e37c2d64f36f118099bb.jsintegrity="sha512-mTsrTFiwfnpLs0I88YzNeKhdAGNoDA/Jv22cwCvpjgh5MDTZhN2PfGCtW3DzGGzIvCgLEHe343wtZPNvEYCZuw=="crossorigin=anonymousdefer></script><scriptsrc=/index.min.80cc62918990f0b9afd15b81ea43df0bc0090a2419660eb4a32b4d122db3bdd007faabd824064bd5d275cbeb3d1e2d2bd650220c94c2ef3aeffb4dc2ef6551f5.jsintegrity="sha512-gMxikYmQ8Lmv0VuB6kPfC8AJCiQZZg60oytNEi2zvdAH+qvYJAZL1dJ1y+s9Hi0r1lAiDJTC7zrv+03C72VR9Q=="crossorigin=anonymousdefer></script></body></html>