<!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>Deploy bare metal - mCaptcha</title><metaname=descriptioncontent="Bare metal deployment is tedious, most of this will be automated with a script in the future."><linkrel=canonicalhref=/docs/self-hosted/bare-metal/><metaname=twitter:cardcontent="summary_large_image"><metaname=twitter:imagecontent="/icon.png"><metaname=twitter:titlecontent="Deploy bare metal"><metaname=twitter:descriptioncontent="Bare metal deployment is tedious, most of this will be automated with a script in the future."><metaname=twitter:sitecontent="@"><metaname=twitter:creatorcontent="@"><metaproperty="og:title"content="Deploy bare metal"><metaproperty="og:description"content="Bare metal deployment is tedious, most of this will be automated with a script in the future."><metaproperty="og:type"content="article"><metaproperty="og:url"content="/docs/self-hosted/bare-metal/"><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 Hostedbare Metal","item":"\/docsself-hostedbare-metal\/"}]}</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>
<spanclass=toggle-dark><svgxmlns="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"><pathd="M21 12.79A9 9 0 1111.21 3 7 7 0 0021 12.79z"/></svg></span><spanclass=toggle-light><svgxmlns="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"><circlecx="12"cy="12"r="5"/><linex1="12"y1="1"x2="12"y2="3"/><linex1="12"y1="21"x2="12"y2="23"/><linex1="4.22"y1="4.22"x2="5.64"y2="5.64"/><linex1="18.36"y1="18.36"x2="19.78"y2="19.78"/><linex1="1"y1="12"x2="3"y2="12"/><linex1="21"y1="12"x2="23"y2="12"/><linex1="4.22"y1="19.78"x2="5.64"y2="18.36"/><linex1="18.36"y1="5.64"x2="19.78"y2="4.22"/></svg></span></button><ulclass="navbar-nav social-nav order-3 order-md-5"><liclass=nav-item><aclass=nav-linkhref=https://github.com/mCaptcha><svgxmlns="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"><pathd="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><spanclass="ms-2 visually-hidden">GitHub</span></a></li></ul><divclass="collapse navbar-collapse order-4 order-md-1"><ulclass="navbar-nav main-nav me-auto order-5 order-md-2"><liclass=nav-item><aclass=nav-linkhref=/about/>About</a></li><liclass=nav-item><aclass=nav-linkhref=/blog/>Blog</a></li><liclass=nav-item><aclass=nav-linkhref=/community/>Community</a></li><liclass=nav-item><aclass=nav-linkhref=/contact/>Contact</a></li><liclass="nav-item active"><aclass=nav-linkhref=/docs/prologue/introduction/>Docs</a></li></ul><divclass="break order-6 d-md-none"></div><formclass="navbar-form flex-grow-1 order-7 order-md-3"><inputid=userinputclass="form-control is-search"type=searchplaceholder="Search docs..."aria-label="Search docs..."autocomplete=off><divid=suggestionsclass="shadow bg-white rounded"></div></form></div></div></header><divclass="wrap container"role=document><divclass=content><divclass="row flex-xl-nowrap"><divclass="col-lg-5 col-xl-4 docs-sidebar"><navclass=docs-linksaria-label="Main navigation"><h3>Prologue</h3><ulclass=list-unstyled><li><aclass=docs-linkhref=/docs/prologue/introduction/>Introduction</a></li></ul><h3>API</h3><ulclass=list-unstyled><li><aclass=docs-linkhref=/docs/api/mcaptcha-system/>mCaptcha System Library</a></li><li><aclass=docs-linkhref=/docs/api/browser/>Browser library</a></li><li><aclass=docs-linkhref=/docs/api/pow-sha256/>pow_sha256</a></li></ul><h3>Help</h3><ulclass=list-unstyled><li><aclass=docs-linkhref=/docs/help/troubleshooting/>Troubleshooting</a></li><li><aclass=docs-linkhref=/docs/help/faq/>FAQ</a></li></ul><h3>self-hosted</h3><ulclass=list-unstyled><li><aclass=docs-linkhref=/docs/self-hosted/getting-started/>Getting started</a></li><li><aclass=docs-linkhref=/docs/self-hosted/docker/>Docker</a></li><li><aclass="docs-link active"href=/docs/self-hosted/bare-metal/>Deploy bare metal</a></li><li><aclass=docs-linkhref=/docs/self-hosted/dependencies/>Databse and cache</a></li></ul></nav></div><navclass="docs-toc d-none d-xl-block col-xl-3"aria-label="Secondary navigation"><divclass=page-links><h3>On this page</h3><navid=TableOfContents><ul><li><ul><li><ahref=#2-configure>2. Configure</a></li><li><ahref=#1-install-postgres-if-you-dont-have-it-already>1. Install postgres if you don’t have it already.</a></li><li><ahref=#2-create-new-user-for-running-mcaptcha>2. Create new user for running <code>mcaptcha</code></a></li><li><ahref=#3-create-new-user-in-postgres>3. Create new user
</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/zsh 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-and-load-mcaptchacachehttpsgithubcommcaptchacache-module>4. Install and load <ahref=https://github.com/mCaptcha/cache><code>mCaptcha/cache</code></a> module:<ahref=#4-install-and-load-mcaptchacachehttpsgithubcommcaptchacache-moduleclass=anchoraria-hidden=true>#</a></h3><p>See <ahref=https://github.com/mCaptcha/cache><code>mCaptcha/cache</code></a> for more
details.</p><h3id=4-build-mcaptcha>4. Build <code>mcaptcha</code><ahref=#4-build-mcaptchaclass=anchoraria-hidden=true>#</a></h3><p>To build <code>mcaptcha</code>, you need the following dependencies:</p><ol><li>rust</li><li>node(<code>v14.16.0</code>)</li><li>yarn(JavaScript package manager)</li><li>make</li></ol><h2id=how-to-build>How to build<ahref=#how-to-buildclass=anchoraria-hidden=true>#</a></h2><ol><li>Install Cargo using <ahref=https://rustup.rs/>rustup</a> with:</li></ol><divclass=highlight><preclass=chroma><codeclass=language-bashdata-lang=bash>$ curl --proto <spanclass=s1>'=https'</span> --tlsv1.2 -sSf https://sh.rustup.rs <spanclass=p>|</span> sh
</code></pre></div><olstart=2><li><p>Install node(<code>v14.16.0</code>)</p></li><li><p>Install yarn(JavaScript package manager)</p></li><li><p>Build with make:</p></li></ol><divclass=highlight><preclass=chroma><codeclass=language-bashdata-lang=bash>$ make dev-env <spanclass=o>&&</span><spanclass=se>\
</code></pre></div><h3id=6-systemd-service-configuration>6. Systemd service configuration:<ahref=#6-systemd-service-configurationclass=anchoraria-hidden=true>#</a></h3><ol><li>Copy the following to <code>/etc/systemd/system/mcaptcha.service</code>:</li></ol><divclass=highlight><preclass=chroma><codeclass=language-systemddata-lang=systemd><spanclass=k>[Unit]</span>
<spanclass=na>Description</span><spanclass=o>=</span><spanclass=s>mCaptcha: a CAPTCHA system that gives attackers a run for their money</span>