DriversRecommendedOutdated drivers can make a good PC feel brokenScan driver issues before chasing fixes manually.Scan NowHalloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan Now×
Skip to content
World desk10 min

How to Self-Host Monica Personal CRM on an Ubuntu VPS (Docker Compose Guide)

A practical Ubuntu VPS guide to running Monica Personal CRM with Docker Compose and MariaDB, securing it behind HTTPS, preserving data and handling updates.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To self-host Monica Personal CRM on an Ubuntu VPS, run Monica’s official Apache Docker image with a MariaDB container, keep both data directories on persistent volumes, and place the application behind a reverse proxy that terminates HTTPS. A practical deployment needs a generated APP_KEY, database credentials, production mode, and a backup plan.

This guide answers “How do I self-host Monica on an Ubuntu VPS?”, provides a working Docker Compose pattern, explains how much RAM Monica needs, and shows how to put it behind HTTPS without exposing MariaDB to the internet.

As an Amazon Associate I earn from qualifying purchases.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

What you need before installing Monica

Monica is an open-source personal relationship management application. The software can be run on your own server without a license fee; hosted Monica is a separate paid service. A self-hosted installation leaves server administration, updates, TLS, backups and account security to you.

VPS requirements

  • An Ubuntu VPS with a public IPv4 address or another reachable address.
  • A domain name such as crm.example.com pointed at the VPS.
  • At least 1.5 GB of RAM. The Monica project README gives this as a recommendation for successful builds and updates; normal runtime use may be lighter, but smaller machines can fail during update builds.
  • Root or sudo access.
  • Enough disk space for the operating system, Docker images, Monica’s uploaded data and MariaDB’s database files.

RAM, disk growth, firewall rules, backup frequency and the VPS provider are operational choices rather than fixed Monica requirements. If you expect several users, frequent file uploads or long retention, choose more storage and memory than the minimum recommendation.

Choose the container or manual route

Decision Docker Compose Manual installation
Setup reproducibility Usually strongest: application and database are declared together. More dependent on host package versions and configuration.
Host-package control Less control because the application runs in an image. More control over PHP, the web server and system services.
Web-server complexity The Apache image serves HTTP; a reverse proxy still handles public HTTPS. An FPM image requires a separate web server. You configure Apache, Nginx or Caddy and PHP yourself.
Updates and backups You still update images, run migrations and back up volumes. You update PHP, Composer dependencies, application files and the database yourself.

The rest of this article uses Docker Compose because it is the most repeatable path on an Ubuntu VPS. A manual-installation section appears later for administrators who do not want containers.

Install Docker and Compose on Ubuntu

Use the Docker installation path supported for your Ubuntu release, then install the Compose plugin. Package names differ between Ubuntu releases and between the Ubuntu archive and Docker’s repository, so follow the current package instructions for your release rather than copying an obsolete repository line.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

After installation, verify both components:

docker --version
docker compose version

If you want to run Docker as your normal account, add that account to the Docker group and start a new login session. Remember that membership in this group grants root-equivalent control over the host.

sudo usermod -aG docker $USER

Until the new session is active, prefix Docker commands with sudo. Before deploying Monica, apply Ubuntu security updates and configure a firewall so only SSH and the public web ports are reachable. Do not allow the MariaDB port from the internet.

Create the Monica Compose project

Make a private application directory

  1. Create a directory owned by your administrative account and enter it.
  2. Create a separate environment file for secrets.
  3. Set restrictive permissions so other unprivileged users cannot read the credentials.
mkdir -p ~/monica
cd ~/monica
touch .env
chmod 600 .env

Generate a strong APP_KEY

Monica uses APP_KEY to protect application data. Generate it once and keep it unchanged for the life of the installation. The project documentation gives this command:

echo -n 'base64:'; openssl rand -base64 32

Copy the complete output, including the base64: prefix, into .env. Losing or changing this key can make existing encrypted data unreadable, so include the environment file in your secure backup procedure.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Write the environment file

Use long, unique passwords for both the Monica database user and the MariaDB root account. The values below are examples; replace every password and the domain with your own values.

APP_ENV=production
APP_KEY=base64:PASTE_THE_GENERATED_VALUE_HERE
DB_HOST=db
DB_DATABASE=monica
DB_USERNAME=monica
DB_PASSWORD=replace-with-a-long-random-password
DB_ROOT_PASSWORD=replace-with-a-different-long-random-password
APP_URL=https://crm.example.com

Keep .env out of public repositories, screenshots and support bundles. If you use source control for the Compose file, commit only a redacted example such as .env.example.

Create compose.yaml

The following pattern runs Monica’s Apache variant and MariaDB. The application listens only on the VPS loopback address, leaving the reverse proxy as the public entry point. The named volumes preserve application storage and database files when containers are recreated.

services:
  app:
    image: monicahq/monica:apache
    restart: unless-stopped
    env_file:
      - .env
    depends_on:
      - db
    ports:
      - "127.0.0.1:8080:80"
    volumes:
      - monica_storage:/var/www/html/storage

  db:
    image: mariadb:latest
    restart: unless-stopped
    environment:
      MYSQL_DATABASE: ${DB_DATABASE}
      MYSQL_USER: ${DB_USERNAME}
      MYSQL_PASSWORD: ${DB_PASSWORD}
      MYSQL_ROOT_PASSWORD: ${DB_ROOT_PASSWORD}
    volumes:
      - monica_db:/var/lib/mysql

volumes:
  monica_storage:
  monica_db:

The Apache image serves Monica’s HTTP application internally. If you choose an FPM image instead, you must add and configure a separate web server; an FPM container does not serve public HTTP by itself. For production, pin image tags that you have checked against Monica’s release notes instead of allowing an unreviewed image change to arrive unexpectedly through latest.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Start Monica and finish first-time setup

  1. Validate the Compose file and environment interpolation:
docker compose config
  1. Start both services in the background:
docker compose up -d
  1. Watch the application log while the database initializes:
docker compose logs -f app

On the first start, wait for database initialization and migrations to complete. A temporary connection error while MariaDB is still starting is normal; wait a little and inspect the logs before changing credentials.

  1. Run Monica’s production setup command once after the initial start:
docker compose exec app php artisan setup:production
  1. Open the site through the local proxy address during testing or through your domain after the reverse proxy is configured, then create the first user account.

Do not run the production setup command repeatedly as a routine restart step. Run it again only when Monica’s upgrade instructions specifically require it.

Check container state

docker compose ps
docker compose logs --tail=100 app
docker compose logs --tail=100 db

The app should remain in an “Up” state, and MariaDB should remain running without an authentication or initialization loop. If you change database credentials after the database volume has already been initialized, the new values do not rewrite existing MariaDB users automatically; either restore the original credentials or change the database user deliberately from inside MariaDB.

Put Monica behind HTTPS

Do not treat the Compose port mapping as a finished public deployment. Monica’s documentation requires production mode and HTTPS for an internet-facing installation. The Apache Compose example serves HTTP and is intended to run behind a proxy; it does not issue certificates or provide TLS by itself.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Reverse-proxy layout

The recommended traffic flow is:

  1. DNS points crm.example.com to the VPS.
  2. The host reverse proxy listens on ports 80 and 443.
  3. The proxy obtains and renews a certificate with your chosen ACME-compatible certificate service.
  4. The proxy forwards requests to http://127.0.0.1:8080.
  5. MariaDB remains on the private Docker network and has no host port mapping.

A minimal Nginx-style proxy block looks like this after your certificate paths are configured:

server {
    listen 443 ssl http2;
    server_name crm.example.com;

    ssl_certificate     /etc/ssl/your-service/fullchain.pem;
    ssl_certificate_key /etc/ssl/your-service/privkey.pem;

    location / {
        proxy_pass http://127.0.0.1:8080;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto https;
    }
}

Use the equivalent settings in Apache or Caddy if that is your host standard. Redirect plain HTTP to HTTPS, permit only the proxy’s public ports through the firewall, and confirm that APP_URL uses the final HTTPS URL. Never expose port 3306 publicly merely to make troubleshooting easier.

Test the public path

  • Visit the HTTPS URL and confirm the browser shows a valid certificate for the exact hostname.
  • Sign in, create a test contact and reload it to verify that requests are reaching Monica through the proxy.
  • Check browser developer tools for mixed-content warnings; these usually indicate an incorrect application URL or missing forwarded-protocol header.
  • Stop the proxy temporarily and confirm the application is not reachable from the internet through port 8080. The loopback binding should prevent direct external access.

Persist and back up Monica data

Monica’s application data is under /var/www/html/storage. The Compose file maps that directory to monica_storage. MariaDB data is stored separately in monica_db. Backing up only the Compose file is not a backup of your contacts.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

What to back up

  • The .env file, protected as a secret.
  • The monica_storage volume, including uploaded files and generated application data.
  • A consistent dump of the MariaDB database, or a database-volume backup performed while MariaDB is safely stopped.
  • Your reverse-proxy configuration and certificate-renewal configuration.

Use a database dump for portability

A logical dump is generally easier to restore to another MariaDB instance than copying live database files. Use the database credentials from .env, write the dump to a directory with restricted permissions, and encrypt it before sending it off the VPS. Schedule backups according to how much contact history you can afford to lose, and keep at least one copy outside the server.

Test a restoration on a separate temporary instance. A backup that has never been restored is an assumption, not a recovery plan.

Protect the volumes

Named volumes survive docker compose down unless you explicitly remove them with the volume-removal option. Do not run destructive cleanup commands until you have verified the backup and identified the exact volume names:

docker volume ls
docker compose down
docker compose up -d

For a planned migration, stop writes, create the database dump and storage archive, copy the Compose and environment files securely, then start the replacement stack and restore the data before allowing users to sign in.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Updating Monica safely

  1. Read the release notes for the Monica image version you intend to deploy and check compatibility with your MariaDB version.
  2. Make a fresh database dump and storage backup.
  3. Record the current image tags and running configuration with docker compose config.
  4. Pull the reviewed image and recreate the app:
docker compose pull app
docker compose up -d app
  1. Watch logs for migrations and run docker compose exec app php artisan setup:production only if the release instructions call for it.
  2. Test login, contact search, notes, reminders and uploaded files before declaring the update complete.

Keep the previous image tag available until the new release has passed those checks. Never delete the database volume as an update shortcut.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Manual installation without containers

Containers are optional. Monica’s project README lists PHP 8.1 or newer, an HTTP server with PHP support such as Apache, Nginx or Caddy, Composer and MySQL for a manual installation. It recommends at least 1.5 GB of RAM because update builds can fail on smaller systems even when everyday use is lighter.

Manual prerequisites

  • Ubuntu with PHP 8.1 or newer and the PHP extensions required by the Monica release.
  • Apache, Nginx or Caddy configured to serve the Monica public directory.
  • Composer available to the deployment user.
  • MySQL, with a database and least-privilege application account.
  • HTTPS termination and a persistent backup strategy.

The manual path gives you direct control over host packages and service files, but every PHP, web-server and Composer update becomes your responsibility. Follow the version-specific installation instructions from the Monica project for the exact checkout, environment generation, database migration and web-root settings. Do not combine a container’s storage directory with a manual install unless you have planned the migration and understand the file ownership changes.

Troubleshoot common failures

The app cannot connect to MariaDB

  • Confirm DB_HOST=db; inside Compose, the service name is the hostname.
  • Check that DB_DATABASE, DB_USERNAME and DB_PASSWORD match the values used when MariaDB initialized.
  • Inspect docker compose logs db for initialization or permission errors.
  • Wait for MariaDB to finish its first startup before restarting the app repeatedly.

“APP_KEY is missing” or encrypted data errors

Check that APP_KEY is present in .env, includes the base64: prefix and is passed to the app through env_file. Do not generate a new key to solve an existing-data error; recover the original key from your protected backup.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The browser shows a 502 or connection refused

Confirm the app container is running, port 8080 is bound on loopback, and the proxy’s upstream is exactly 127.0.0.1:8080. A 502 from the proxy is different from a Monica application error: first inspect the proxy error log, then the app log.

HTTPS redirects incorrectly or links use HTTP

Set APP_ENV=production, use an HTTPS APP_URL, pass X-Forwarded-Proto https, and reload the proxy. Clear an old browser session only after verifying the server-side settings.

The VPS runs out of memory during an update

Keep at least the README’s 1.5 GB recommendation available, stop unrelated services, and check memory and swap before retrying. If builds still fail, move to a larger VPS rather than repeatedly killing containers during a migration.

Is self-hosting Monica worth it?

Self-hosting is a good fit when you want control of the server and data, can maintain Ubuntu and Docker, and will actually test backups. Docker Compose makes the initial deployment reproducible, while HTTPS, updates, credentials and recovery remain operational work. Manual installation is reasonable when host-level PHP control matters more than container isolation. In either case, the non-negotiable pieces are a strong APP_KEY, persistent application and database storage, production mode, HTTPS and a tested restore procedure.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.