30 lines
No EOL
14 KiB
HTML
30 lines
No EOL
14 KiB
HTML
<!doctype html><html lang=en-us><head><meta charset=utf-8><meta http-equiv=x-ua-compatible content="ie=edge"><meta name=viewport content="width=device-width,initial-scale=1,shrink-to-fit=no"><link rel=preload as=font href=/fonts/vendor/jost/jost-v4-latin-regular.woff2 type=font/woff2 crossorigin><link rel=preload as=font href=/fonts/vendor/jost/jost-v4-latin-700.woff2 type=font/woff2 crossorigin><link rel=stylesheet href=/main.cb7ce0ee5bb858da9f19d6761af119ed09838c22aab74a98a86de0d1d8665505052dd5107c252204393d6aefa5d54360e298abab14cb2b23cb0926b1ed116fb4.css integrity="sha512-y3zg7lu4WNqfGdZ2GvEZ7QmDjCKqt0qYqG3g0dhmVQUFLdUQfCUiBDk9au+l1UNg4pirqxTLKyPLCSax7RFvtA==" crossorigin=anonymous><noscript><style>img.lazyload{display:none}</style></noscript><meta name=robots content="index, follow"><meta name=googlebot content="index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1"><meta name=bingbot content="index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1"><title>Databse and cache - mCaptcha</title><meta name=description content="mCaptcha server requires dependencies like a Postgres database and a Redis cache"><link rel=canonical href=/docs/self-hosted/dependencies/><meta name=twitter:card content="summary_large_image"><meta name=twitter:image content="/icon.png"><meta name=twitter:title content="Databse and cache"><meta name=twitter:description content="mCaptcha server requires dependencies like a Postgres database and a Redis cache"><meta name=twitter:site content="@"><meta name=twitter:creator content="@"><meta property="og:title" content="Databse and cache"><meta property="og:description" content="mCaptcha server requires dependencies like a Postgres database and a Redis cache"><meta property="og:type" content="article"><meta property="og:url" content="/docs/self-hosted/dependencies/"><meta property="og:image" content="/icon.png"><meta property="article:modified_time" content="2021-07-21T15:49:53+05:30"><meta property="og:site_name" content="mCaptcha"><meta property="article:publisher" content="https://www.facebook.com/"><meta property="article:author" content="https://www.facebook.com/"><meta property="og:locale" content="en_US"><script type=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><meta name=theme-color content="#fff"><link rel=apple-touch-icon sizes=180x180 href=/apple-touch-icon.png><link rel=icon type=image/png sizes=32x32 href=/favicon-32x32.png><link rel=icon type=image/png sizes=16x16 href=/favicon-16x16.png><link rel=manifest href=/site.webmanifest></head><body class="docs single"><div class="header-bar fixed-top"></div><header class="navbar fixed-top navbar-expand-md navbar-light"><div class=container><input class="menu-btn order-0" type=checkbox id=menu-btn>
|
|
<label class="menu-icon d-md-none" for=menu-btn><span class=navicon></span></label><a class="navbar-brand order-1 order-md-0 me-auto" href=/>mCaptcha</a>
|
|
<button id=mode class="btn btn-link order-2 order-md-4" type=button aria-label="Toggle mode">
|
|
<span class=toggle-dark><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentcolor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-moon"><path d="M21 12.79A9 9 0 1111.21 3 7 7 0 0021 12.79z"/></svg></span><span class=toggle-light><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentcolor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-sun"><circle cx="12" cy="12" r="5"/><line x1="12" y1="1" x2="12" y2="3"/><line x1="12" y1="21" x2="12" y2="23"/><line x1="4.22" y1="4.22" x2="5.64" y2="5.64"/><line x1="18.36" y1="18.36" x2="19.78" y2="19.78"/><line x1="1" y1="12" x2="3" y2="12"/><line x1="21" y1="12" x2="23" y2="12"/><line x1="4.22" y1="19.78" x2="5.64" y2="18.36"/><line x1="18.36" y1="5.64" x2="19.78" y2="4.22"/></svg></span></button><ul class="navbar-nav social-nav order-3 order-md-5"><li class=nav-item><a class=nav-link href=https://github.com/mCaptcha><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentcolor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-github"><path d="M9 19c-5 1.5-5-2.5-7-3m14 6v-3.87a3.37 3.37.0 00-.94-2.61c3.14-.35 6.44-1.54 6.44-7A5.44 5.44.0 0020 4.77 5.07 5.07.0 0019.91 1S18.73.65 16 2.48a13.38 13.38.0 00-7 0C6.27.65 5.09 1 5.09 1A5.07 5.07.0 005 4.77 5.44 5.44.0 003.5 8.55c0 5.42 3.3 6.61 6.44 7A3.37 3.37.0 009 18.13V22"/></svg><span class="ms-2 visually-hidden">GitHub</span></a></li></ul><div class="collapse navbar-collapse order-4 order-md-1"><ul class="navbar-nav main-nav me-auto order-5 order-md-2"><li class=nav-item><a class=nav-link href=/about/>About</a></li><li class=nav-item><a class=nav-link href=/blog/>Blog</a></li><li class=nav-item><a class=nav-link href=/community/>Community</a></li><li class=nav-item><a class=nav-link href=/contact/>Contact</a></li><li class="nav-item active"><a class=nav-link href=/docs/prologue/introduction/>Docs</a></li></ul><div class="break order-6 d-md-none"></div><form class="navbar-form flex-grow-1 order-7 order-md-3"><input id=userinput class="form-control is-search" type=search placeholder="Search docs..." aria-label="Search docs..." autocomplete=off><div id=suggestions class="shadow bg-white rounded"></div></form></div></div></header><div class="wrap container" role=document><div class=content><div class="row flex-xl-nowrap"><div class="col-lg-5 col-xl-4 docs-sidebar"><nav class=docs-links aria-label="Main navigation"><h3>Prologue</h3><ul class=list-unstyled><li><a class=docs-link href=/docs/prologue/introduction/>Introduction</a></li></ul><h3>API</h3><ul class=list-unstyled><li><a class=docs-link href=/docs/api/mcaptcha-system/>mCaptcha System Library</a></li><li><a class=docs-link href=/docs/api/browser/>Browser library</a></li><li><a class=docs-link href=/docs/api/pow-sha256/>pow_sha256</a></li></ul><h3>Help</h3><ul class=list-unstyled><li><a class=docs-link href=/docs/help/troubleshooting/>Troubleshooting</a></li><li><a class=docs-link href=/docs/help/faq/>FAQ</a></li></ul><h3>self-hosted</h3><ul class=list-unstyled><li><a class=docs-link href=/docs/self-hosted/getting-started/>Getting started</a></li><li><a class=docs-link href=/docs/self-hosted/docker/>Docker</a></li><li><a class=docs-link href=/docs/self-hosted/bare-metal/>Deploy bare metal</a></li><li><a class="docs-link active" href=/docs/self-hosted/dependencies/>Databse and cache</a></li></ul></nav></div><nav class="docs-toc d-none d-xl-block col-xl-3" aria-label="Secondary navigation"><div class=page-links><h3>On this page</h3><nav id=TableOfContents><ul><li><a href=#notes>Notes</a><ul><li><a href=#database>Database</a></li><li><a href=#redis>Redis</a></li></ul></li><li><a href=#instructions>Instructions</a><ul><li><a href=#docker>Docker</a></li><li><a href=#database-1>Database</a></li><li><a href=#redis-1>Redis</a></li><li><a href=#1-install-postgres-if-you-dont-have-it-already>1. Install Postgres if you don’t have it already.</a></li><li><a href=#2-create-new-user-for-running-mcaptcha>2. Create new user for running <code>mCaptcha</code></a></li><li><a href=#3-create-new-user-in-postgres>3. Create new user in Postgres</a></li><li><a href=#4-install-mcaptchacachehttpsgithubcommcaptchacache>4. Install <a href=https://github.com/mCaptcha/cache><code>mCaptcha/cache</code></a></a></li></ul></li></ul></nav></div></nav><main class="docs-content col-lg-11 col-xl-9"><h1>Databse and cache</h1><p class=lead>mCaptcha server requires dependencies like a Postgres database and a Redis cache</p><h2 id=notes>Notes<a href=#notes class=anchor aria-hidden=true>#</a></h2><h3 id=database>Database<a href=#database class=anchor aria-hidden=true>#</a></h3><ul><li><p>Database migrations are baked into the server binary so don’t worry
|
|
about them.</p></li><li><p>When compiling from source, unset database configuration(comment out
|
|
database configuration/ <code>unset</code> relevant environment variables).
|
|
<code>mCaptcha</code> uses <a href=https://crates.io/crates/sqlx><code>sqlx</code></a> database client
|
|
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><h3 id=redis>Redis<a href=#redis class=anchor aria-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
|
|
<a href=https://github.com/mCaptcha/cache>cache</a> to overcome some of Redis'
|
|
limitations.</p></li></ul><h2 id=instructions>Instructions<a href=#instructions class=anchor aria-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><h3 id=docker>Docker<a href=#docker class=anchor aria-hidden=true>#</a></h3><h3 id=database-1>Database<a href=#database-1 class=anchor aria-hidden=true>#</a></h3><p>Download and run Postgres</p><div class=highlight><pre class=chroma><code class=language-bash data-lang=bash>docker create --name mcaptcha-postgres <span class=se>\
|
|
</span><span class=se></span> -e <span class=nv>POSTGRES_PASSWORD</span><span class=o>=</span><databse-password> <span class=se>\
|
|
</span><span class=se></span> -p 5432:5432 <span class=se>\
|
|
</span><span class=se></span> postgres <span class=o>&&</span> docker start mcaptcha-postgres
|
|
</code></pre></div><h3 id=redis-1>Redis<a href=#redis-1 class=anchor aria-hidden=true>#</a></h3><div class=highlight><pre class=chroma><code class=language-bash data-lang=bash>docker create --name mcaptcha-cache <span class=se>\
|
|
</span><span class=se></span> -p 6379:6379 <span class=se>\
|
|
</span><span class=se></span> mcaptcha/cache <span class=o>&&</span> docker start mcaptcha-cache
|
|
</code></pre></div><p>See <a href=https://github.com/mCaptcha/cache>mCaptcha/cache</a> for more
|
|
details.</p><h3 id=1-install-postgres-if-you-dont-have-it-already>1. Install Postgres if you don’t have it already.<a href=#1-install-postgres-if-you-dont-have-it-already class=anchor aria-hidden=true>#</a></h3><p>For Debian based distributions:</p><div class=highlight><pre class=chroma><code class=language-bash data-lang=bash>sudo apt install postgres
|
|
</code></pre></div><h3 id=2-create-new-user-for-running-mcaptcha>2. Create new user for running <code>mCaptcha</code><a href=#2-create-new-user-for-running-mcaptcha class=anchor aria-hidden=true>#</a></h3><div class=highlight><pre class=chroma><code class=language-bash data-lang=bash>$ sudo useradd -b /srv -m -s /usr/bin/bash mcaptcha
|
|
</code></pre></div><h3 id=3-create-new-user-in-postgres>3. Create new user in Postgres<a href=#3-create-new-user-in-postgres class=anchor aria-hidden=true>#</a></h3><div class=highlight><pre class=chroma><code class=language-bash data-lang=bash>$ sudo -iu postgres <span class=c1># switch to `postgres` user</span>
|
|
$ psql
|
|
<span class=nv>postgres</span><span class=o>=</span><span class=c1># CREATE USER mcaptcha WITH PASSWORD 'my super long password and yes you need single quote';</span>
|
|
$ createdb -O mcaptcha mcaptcha <span class=c1># create db 'mcaptcha' with 'mcaptcha' as owner</span>
|
|
</code></pre></div><h3 id=4-install-mcaptchacachehttpsgithubcommcaptchacache>4. Install <a href=https://github.com/mCaptcha/cache><code>mCaptcha/cache</code></a><a href=#4-install-mcaptchacachehttpsgithubcommcaptchacache class=anchor aria-hidden=true>#</a></h3><p>See <a href=https://github.com/mCaptcha/cache><code>mCaptcha/cache</code></a> for more
|
|
details.</p><p class=edit-page><a href=https://github.com/mCaptcha/website/blob/master/content/docs/self-hosted/dependencies.md><svg xmlns="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"><path d="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><div class="docs-navigation d-flex justify-content-between"><a href=/docs/api/pow-sha256/><div class="card my-1"><div class="card-body py-2">← pow_sha256</div></div></a><a class=ms-auto href=/docs/help/troubleshooting/><div class="card my-1"><div class="card-body py-2">Troubleshooting →</div></div></a></div></main></div></div></div><footer class="footer text-muted"><div class=container><div class=row><div class="col-lg-8 order-last order-lg-first"><ul class=list-inline><li class=list-inline-item>Powered by <a href=https://gohugo.io/>Hugo</a>, and <a href=https://getdoks.org/>Doks</a></li></ul></div><div class="col-lg-8 order-first order-lg-last text-lg-end"><ul class=list-inline><li class=list-inline-item><a href=/about/>About</a></li><li class=list-inline-item><a href=/donate>Donate</a></li><li class=list-inline-item><a href=/privacy-policy/>Privacy</a></li><li class=list-inline-item><a href=/security>Security</a></li><li class=list-inline-item><a href=https://stats.uptimerobot.com/GK7VLFJnBl>Status</a></li><li class=list-inline-item><a href=/thanks>Thanks</a></li></ul></div></div></div></footer><script src=/main.min.db67f0caa6a5788b691b9509981d6e5943f4b8d829170a674f468d4b23671ce4017c47a0a22116a8fc2f2de556c8b48f1afecd86707066f2f022c5dd83e8ea3c.js integrity="sha512-22fwyqaleItpG5UJmB1uWUP0uNgpFwpnT0aNSyNnHOQBfEegoiEWqPwvLeVWyLSPGv7NhnBwZvLwIsXdg+jqPA==" crossorigin=anonymous defer></script><script src=/index.min.aab62a01bb69c52990d1e9a9072a01da2b9367f1a41ff3fa2b71ccdec4240b589f7196886485c3dd15f0598e76f83630d9f9432840f1758143eb96b263dcbe1e.js integrity="sha512-qrYqAbtpxSmQ0empByoB2iuTZ/GkH/P6K3HM3sQkC1ifcZaIZIXD3RXwWY52+DYw2flDKEDxdYFD65ayY9y+Hg==" crossorigin=anonymous defer></script></body></html> |