<!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.499b994519858c1434b91f11437691401e5c08a553d2187e8f7accfadbee2b0321c33192a4c63dd24fdeee64f99eb025f338561b35e72c340dfb249788196c20.cssintegrity="sha512-SZuZRRmFjBQ0uR8RQ3aRQB5cCKVT0hh+j3rM+tvuKwMhwzGSpMY90k/e7mT5nrAl8zhWGzXnLDQN+ySXiBlsIA=="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