Skip to content

How to Deploy Flarum on a VPS

Updated Oct 2026

verified on Ubuntu 26.04 · Oct 2026
We earn commissions when you shop through the links below. Full disclosure →

Self-host Flarum on a small VPS — the lightweight PHP forum, installed with Composer on PHP-FPM and MariaDB behind Caddy HTTPS, with a restore-tested backup and a Composer upgrade path.

Before you start
  • A VPS with 1 GB+ RAM (Flarum's own floor is 512 MB; PHP-FPM and MariaDB want the extra room, and a 512 MB box has little left for extensions)
  • A fresh Ubuntu 24.04 or 26.04 server with root/sudo SSH access
  • A domain or subdomain you can point at the server
Need a box for this guide? Kamatera's free tier lets you spin one up now.Start free on Kamatera → (opens in new tab)

What Flarum is

Flarum is a modern, lightweight forum: threaded discussions, tags, notifications, a clean mobile-friendly interface and a large extension ecosystem. It is MIT-licensed, written in PHP with a Mithril.js front end, stores its data in MySQL or MariaDB, and is rated 3 / 5 to deploy. That rating is not about Flarum being hard to run. It is because upstream ships no Docker image: you install it with Composer onto a normal PHP web stack, so there are more moving parts to set up than with a single docker compose up.

This guide does exactly that on one Ubuntu server: PHP-FPM runs Flarum, MariaDB stores it, and Caddy serves it over automatic HTTPS. It picks up from "you have a server" and ends with a forum on HTTPS, a restore-tested backup and an upgrade routine. For help choosing a provider and tier, see Best VPS for self-hosting.

Server sizing

On this guide's verification run (an Ubuntu 26.04 test box, idle right after install; the catalog has no measurement for Flarum), PHP-FPM held about 70 MB and MariaDB about 150 MB of resident memory, roughly 220 MB together. Flarum itself is frugal, but a database server and a PHP process pool are not free, and every extension adds some. A 1 GB VPS is the comfortable minimum; 512 MB is Flarum's stated floor and works for a tiny private forum with no extensions.

Disk use is dominated by the database and uploaded avatars and attachments. The install itself, including Composer's vendor directory, measured about 140 MB on that run.

Prepare the server

Update the system and install the web stack: PHP-FPM with the extensions Flarum requires, MariaDB, Composer, and Caddy as the web server.

sudo apt-get update && sudo apt-get -y upgrade
sudo apt-get install -y curl openssl ufw dnsutils unzip caddy composer mariadb-server \
  php-fpm php-mysql php-curl php-dom php-gd php-mbstring php-xml php-zip
php -v | head -1

If you're logged in as root, create a non-root sudo user and continue as that user:

adduser deploy
usermod -aG sudo deploy

Then open only SSH and the two ports Caddy needs:

sudo ufw allow OpenSSH
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw --force enable

MariaDB listens on localhost only by default, so nothing about the database is exposed to the internet. Keep it that way.

Where to host itaffiliate disclosure
Hetzner Cloudrun it on
2 vCPU · 4 GB RAM · 80 GB SSD · $23.59/mo
Get Hetzner Cloud (opens in new tab)
Kamaterafree trial
1 vCPU · 1 GB RAM · 20 GB SSD · $4.00/mo
Start free on Kamatera → (opens in new tab)
DigitalOceanalso works on
1 vCPU · 1 GB RAM · 25 GB SSD · $6.00/mo
Deploy on DigitalOcean → (opens in new tab)

Paid link — we earn a commission if you shop through it.

Create the database

Create a database and a dedicated user, with a random password held in a shell variable for the next step. The guard makes the step safe to re-run: regenerating the password for an existing user would break the install.

if [ ! -f /var/www/flarum/config.php ]; then
  DBPASS=$(openssl rand -hex 16)
  sudo mariadb -e "CREATE DATABASE IF NOT EXISTS flarum CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
    CREATE USER IF NOT EXISTS 'flarum'@'localhost' IDENTIFIED BY '$DBPASS';
    ALTER USER 'flarum'@'localhost' IDENTIFIED BY '$DBPASS';
    GRANT ALL ON flarum.* TO 'flarum'@'localhost';"
fi
sudo mariadb -e "SHOW DATABASES LIKE 'flarum';"

Install Flarum

Flarum is installed with Composer into /var/www/flarum. This is the same command as upstream's install guide; it fetches the current stable release:

sudo mkdir -p /var/www/flarum && sudo chown "$USER": /var/www/flarum
cd /var/www/flarum
[ -f composer.json ] || composer create-project flarum/flarum . --no-interaction
ls

Now run Flarum's installer from the command line, which skips the web wizard and keeps the admin password out of a browser form. Set your forum's address first (this guide uses forum.example.com; replace it with yours):

cd /var/www/flarum
DOMAIN=forum.example.com
ADMIN_PASS=$(openssl rand -hex 12)
if [ ! -f config.php ]; then
cat > install.yml <<EOF
debug: false
baseUrl: https://$DOMAIN
databaseConfiguration:
  driver: mysql
  host: localhost
  port: 3306
  database: flarum
  username: flarum
  password: "$DBPASS"
  prefix: ""
adminUser:
  username: admin
  password: "$ADMIN_PASS"
  email: admin@$DOMAIN
settings:
  forum_title: My Forum
EOF
php flarum install --file install.yml
rm -f install.yml
echo "admin password: $ADMIN_PASS"
fi
ls config.php

Write the admin password down now: it is printed once and not stored in plain text anywhere. Then hand the directory to the PHP user, which needs write access to it (notably storage/ and public/assets/), and add the scheduler that Flarum extensions rely on:

sudo chown -R www-data:www-data /var/www/flarum
echo '* * * * * www-data cd /var/www/flarum && php flarum schedule:run >> /dev/null 2>&1' \
  | sudo tee /etc/cron.d/flarum

HTTPS + domain

Create an A record for your forum's hostname (say forum.example.com) pointing at the server's public IP, and confirm it resolves before requesting a certificate:

dig +short forum.example.com

Caddy replaces the usual nginx or Apache setup: one site block serves the public directory, hands PHP to PHP-FPM, and gets its own certificate. See Automatic HTTPS with Caddy for how that works. Replace the whole Caddyfile (/etc/caddy/Caddyfile) and restart Caddy:

sudo tee /etc/caddy/Caddyfile >/dev/null <<EOF
forum.example.com {
    root * /var/www/flarum/public
    encode zstd gzip
    php_fastcgi unix//run/php/php-fpm.sock
    file_server
}
EOF
sudo systemctl restart caddy

Caddy requests the certificate on the first visit and renews it on its own. Open https://forum.example.com and confirm the padlock. Check the forum's API answers too:

curl -s https://forum.example.com/api | head -c 120; echo

First login and hardening

Sign in as admin with the password the installer printed, then:

  1. Open the Administration panel from your user menu and set the forum title, description and welcome banner.
  2. Under Mail, configure SMTP. Without it Flarum cannot send password resets or notifications, and a forgotten admin password becomes a database job. A transactional mail provider's free tier is plenty.
  3. Change the admin email from the placeholder address to one you control.
  4. Review Settings → Registration and decide whether sign-ups need email confirmation; forums that are open to the public attract spam fast.
  5. Keep extensions to the ones you need. Each is third-party PHP running with your forum's privileges, and each one is a future upgrade to keep compatible.

Backups

State lives in two places: the database and the files Flarum writes (config.php, uploaded avatars and attachments under public/assets, and storage). Back up both. Start with a logical database dump:

cd ~
sudo mariadb-dump --single-transaction flarum > flarum-db-$(date +%F).sql
chmod 600 flarum-db-$(date +%F).sql
test -s flarum-db-$(date +%F).sql && ls -lh flarum-db-*.sql

Then archive the files. The archive holds config.php, which contains the database password, so both backup commands restrict their files to the owner:

cd ~
sudo tar czf flarum-files-$(date +%F).tar.gz -C /var/www/flarum config.php public/assets storage
sudo chmod 600 flarum-files-*.tar.gz
ls -lh flarum-files-*.tar.gz

Copy both off the server (object storage, another machine, anywhere that survives this VPS dying) and run the pair from cron. A backup you have never restored is a guess, so prove the dump on a scratch database. It should report a non-zero user count:

cd ~
sudo mariadb -e "DROP DATABASE IF EXISTS flarum_restore; CREATE DATABASE flarum_restore;"
sudo mariadb flarum_restore < flarum-db-$(date +%F).sql
sudo mariadb -N -e "SELECT COUNT(*) FROM flarum_restore.users;"
sudo mariadb -e "DROP DATABASE flarum_restore;"

For a real restore onto a new server, redo the install steps through the composer create-project command (skip the installer), create the database and user, load the dump into flarum, unpack the files archive over /var/www/flarum, set the ownership again and reload Caddy.

Upgrades

Flarum upgrades are Composer updates. Read the release notes first, take a backup (previous section), and check that every extension you run supports the new version. Then, as the web user:

cd /var/www/flarum
sudo -u www-data env COMPOSER_HOME=/var/www/flarum/storage/.composer \
  composer update --prefer-dist --no-dev -a --with-all-dependencies --no-interaction
sudo -u www-data php flarum migrate
sudo -u www-data php flarum cache:clear

A minor release is usually painless. A major release is a project of its own: extensions must be updated or replaced first, so follow upstream's upgrade guide step by step instead of running a blanket composer update. If an upgrade breaks the forum, restore the database dump and the files archive and you are back where you started.

Troubleshooting

A blank page or a 500 error. Look at /var/www/flarum/storage/logs/ first; Flarum writes the real exception there. The usual causes are wrong ownership (re-run the chown -R www-data:www-data command) or a PHP extension missing from the apt-get install list.

Caddy returns 502. PHP-FPM is down or the socket path is wrong. Run systemctl status php*-fpm and check that /run/php/php-fpm.sock exists; the version-independent path is a symlink the Ubuntu package maintains.

Caddy never gets a certificate. Confirm dig +short forum.example.com returns the server's IP and that your provider's network-level firewall, not just ufw, allows inbound 80 and 443. A blocked port 80 silently breaks the ACME challenge.

The forum loads but without styling, or links point at the wrong address. baseUrl in config.php must match the address visitors use, including https. Edit it, then run sudo -u www-data php flarum cache:clear.

Extensions can't be installed from the admin panel. Flarum's own panel does not install packages; extensions are added with composer require as the web user, then enabled in the admin panel.

Verification + next steps

Not exercised in our test run: the new-user step and the DNS check against your real domain (we ran on a throwaway box with a temporary hostname).

You're done when https://forum.example.com loads with a valid certificate, you can sign in as admin, php flarum commands run as www-data without permission errors, outgoing mail works from the admin panel's test, and you have restored a backup into a scratch database at least once.

From there, create your tags and categories, pick a theme and an extension or two, and invite your first members. For the ranked server picks and the app's catalog details, see Best VPS for self-hosting and the Flarum entry.

Next steps

How to self-host Flarum →Automatic HTTPS with Caddy →Run Claude Code with Ollama on Your Own VPS →Deploy Coolify on a VPS →How to Deploy Actual Budget on a VPS →How to Deploy AFFiNE on a VPS →How to Deploy AnythingLLM on a VPS →How to Deploy Appwrite on a VPS →How to Deploy Audiobookshelf on a VPS →How to Deploy Authelia on a VPS →How to Deploy authentik on a VPS →How to Deploy Baserow on a VPS →How to Deploy Beszel on a VPS →How to Deploy Bitwarden on a VPS →How to Deploy BookStack on a VPS →How to Deploy CapRover on a VPS →How to Deploy Checkmate on a VPS →How to Deploy copyparty on a VPS →How to Deploy Directus on a VPS →How to Deploy Discourse on a VPS →How to Deploy docker-mailserver on a VPS →How to Deploy Docmost on a VPS →How to Deploy Dokku on a VPS →How to Deploy Dokploy on a VPS →How to Deploy Firefly III on a VPS →How to Deploy Forgejo on a VPS →How to Deploy Gatus on a VPS →How to Deploy Ghost on a VPS →How to Deploy Ghostfolio on a VPS →How to Deploy Gitea on a VPS →How to Deploy a GitHub Actions Self-Hosted Runner on a VPS →How to Deploy GitLab on a VPS →How to Deploy GlitchTip on a VPS →How to Deploy Grafana on a VPS →How to Deploy Graylog on a VPS →How to Deploy Headscale on a VPS →How to Deploy Healthchecks on a VPS →How to Deploy Home Assistant on a VPS →How to Deploy Immich on a VPS →How to Deploy Infisical on a VPS →How to Deploy Invoice Ninja on a VPS →How to Deploy Jan on a VPS →How to Deploy Jellyfin on a VPS →How to Deploy Kanboard on a VPS →How to Deploy Karakeep on a VPS →How to Deploy Keycloak on a VPS →How to Deploy Leantime on a VPS →How to Deploy LibreChat on a VPS →How to Deploy Linkwarden on a VPS →How to Deploy LocalAI on a VPS →How to Deploy Mailcow on a VPS →How to Deploy Mailu on a VPS →How to Deploy Matomo on a VPS →How to Deploy Mattermost on a VPS →How to Deploy Meilisearch on a VPS →How to Deploy Memos on a VPS →How to Deploy a Minecraft Server on a VPS →How to Deploy n8n on a VPS →How to Deploy Navidrome on a VPS →How to Deploy NetBird on a VPS →How to Deploy Netdata on a VPS →How to Deploy Nextcloud on a VPS →How to Deploy Next.js to a VPS →How to Deploy Nginx Proxy Manager on a VPS →How to Deploy NocoDB on a VPS →How to Deploy ntfy on a VPS →How to Deploy Odoo on a VPS →How to Deploy Ollama on a VPS →How to Deploy ONLYOFFICE Docs on a VPS →How to Deploy Open WebUI on a VPS →How to Deploy OpenHands on a VPS →How to Deploy OpenObserve on a VPS →How to Deploy OpenProject on a VPS →How to Deploy Outline on a VPS →How to Deploy Pangolin on a VPS →How to Deploy Paperless-ngx on a VPS →How to Deploy Passbolt on a VPS →How to Deploy Plane on a VPS →How to Deploy Plausible Analytics on a VPS →How to Deploy Plex Media Server on a VPS →How to Deploy Pocket ID on a VPS →How to Deploy PocketBase on a VPS →How to Deploy Prometheus on a VPS →How to Deploy Psono on a VPS →How to Deploy Radarr on a VPS →How to Deploy Rocket.Chat on a VPS →How to Deploy SigNoz on a VPS →How to Deploy Sonarr on a VPS →How to Deploy Stalwart on a VPS →How to Deploy Stirling-PDF on a VPS →How to Deploy Supabase on a VPS →How to Deploy Synapse on a VPS →How to Deploy Taiga on a VPS →How to Deploy TeamPass on a VPS →How to Deploy Tinyauth on a VPS →How to Deploy Traefik on a VPS →How to Deploy Trilium on a VPS →How to Deploy Twenty CRM on a VPS →How to Deploy Umami on a VPS →How to Deploy Uptime Kuma on a VPS →How to Deploy Vaultwarden on a VPS →How to Deploy Vikunja on a VPS →How to Deploy wg-easy on a VPS →How to Deploy Wiki.js on a VPS →How to Deploy WordPress on a VPS →How to Deploy Zabbix on a VPS →How to Deploy Zitadel on a VPS →How to Deploy Zulip on a VPS →Docker & Compose on Ubuntu 26.04 →Building AI Workflows with n8n →Install Open WebUI with Ollama →Adding AI-Powered Insights to Plausible Analytics →Building AI-Powered Apps with Supabase and pgvector →

We use analytics cookies (Google Analytics, PostHog) to see which guides are useful. No ad networks, no cross-site tracking. See our privacy policy.