<!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.f4e82f75f039986a07346a99687f11e3218d588abe9b9daa7d0673b1a7aaee5b689ec69619c26a2962d5a124bed33807d58bd84180c249bbb8eddc33c5ef5baa.cssintegrity="sha512-9OgvdfA5mGoHNGqZaH8R4yGNWIq+m52qfQZzsaeq7ltonsaWGcJqKWLVoSS+0zgH1YvYQYDCSbu47dwzxe9bqg=="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-hosted/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-hosted/dependencies/"><metaproperty="og:image"content="/icon.png"><metaproperty="article:modified_time"content="2022-08-01T20:24:18+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><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>\
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