Database and cache
mCaptcha server requires dependencies like a Postgres database and a Redis cache
Notes
Database
Database migrations are baked into the server binary so don’t worry about them.
When compiling from source, unset database configuration(comment out database configuration/
unset
relevant environment variables).mCaptcha
usessqlx
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.
Redis
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.
mCaptcha uses a custom Redis module called cache to overcome some of Redis' limitations.
Instructions
Once again, there are two ways to go about this:
- Docker
- Bare metal
Docker
Database
Download and run Postgres
1docker create --name mcaptcha-postgres \
2 -e POSTGRES_PASSWORD=<database-password> \
3 -p 5432:5432 \
4 postgres && docker start mcaptcha-postgres
Redis
1docker create --name mcaptcha-cache \
2 -p 6379:6379 \
3 mcaptcha/cache && docker start mcaptcha-cache
See mCaptcha/cache for more details.
1. Install Postgres if you don’t have it already.
For Debian based distributions:
1sudo apt install postgres
2. Create new user for running mCaptcha
1$ sudo useradd -b /srv -m -s /usr/bin/bash mcaptcha
3. Create new user in Postgres
1$ sudo -iu postgres # switch to `postgres` user
2$ psql
3postgres=# CREATE USER mcaptcha WITH PASSWORD 'my super long password and yes you need single quote';
4$ createdb -O mcaptcha mcaptcha # create db 'mcaptcha' with 'mcaptcha' as owner
4. Install mCaptcha/cache
See mCaptcha/cache
for more
details.