Installing with the server installer
Install Structam as a systemd service on Debian, Ubuntu or the RHEL family with install.sh: steps, options, secrets, re-runs, Caddy and the hardened units.
On this page
Status. Tested: the installer run for real in an Ubuntu 24.04 systemd container (arm64) against an external PostgreSQL 18, re-run (nothing restarted, the secret key kept), with --role worker and with --uninstall; dry runs on Debian 13 and Rocky Linux 9 containers; the units verified with systemd-analyze verify (systemd 255). Not yet run: --local-postgres (the distribution's PostgreSQL packages), and an install on a real server or a RHEL-family host with systemd.
deploy/install/install.sh installs the structam binary as a systemd service on the host itself, with no containers. It needs root, systemd, and the binary for the host's CPU from the release archive KazLabs provides. It supports Debian 12 and 13, Ubuntu 22.04 and 24.04 (apt), and RHEL, Rocky Linux and AlmaLinux 9 and 10 (dnf).
Install
# PostgreSQL elsewhere (recommended for production): a file holding the connection string, mode 0600.
umask 077; echo 'postgres://structam:[email protected]:5432/structam?sslmode=verify-full' > /root/structam-db
sudo deploy/install/install.sh --dry-run --binary ./structam --public-url https://structam.example.com \
--database-url-file /root/structam-db # prints what it would do; changes nothing
sudo deploy/install/install.sh --binary ./structam --public-url https://structam.example.com \
--database-url-file /root/structam-dbOr with PostgreSQL from the distribution on the same host, which must be 16 or newer (Debian 13, Ubuntu 24.04, RHEL 9 with the postgresql:16 module, RHEL 10). Debian 12 and Ubuntu 22.04 ship older releases and are refused.
sudo deploy/install/install.sh --binary ./structam --public-url https://structam.example.com --local-postgresWhat it does
It prints each step as == N. Title:
- Packages: only with
--local-postgres. It installs the distribution'spostgresql; on the RHEL family it enables thepostgresql:16module stream when there is one, runspostgresql-setup --initdband adds a scram-sha-256 loopback rule for thestructamdatabase ahead of the distribution'sidentrules, after a backup ofpg_hba.conf. - User: the
structamsystem user and group (no home, no shell). - Settings and secrets:
/etc/structam(0750 root:structam);/etc/structam/secretsholdingsecret_key,database_urlandbootstrap_admin_password(each 0640 root:structam, generated once and never replaced by a re-run); and the env file/etc/structam/structam.env(0600 root), which names the secret files withSTRUCTAM_<NAME>_FILEand holds no secret itself. - Binary:
/usr/local/bin/structam, replaced only when it differs; the previous one is kept asstructam.previous. The new binary must runstructam versionbefore it replaces the old one. - Units:
structam-<role>.serviceandstructam-migrate.service. - Database schema:
systemctl start structam-migrate(roleall, or any role with--migrate). - Service: enabled, (re)started when anything changed, and waited for until
structam healthcheckpasses; thenstructam doctorprints its checklist.
The closing message says how to sign in. Every host installed with role all or serve generates its own bootstrap_admin_password, but only the first node to start on a database without users creates the administrator, with its own password. The installer tells you to sign in with this host's password only when that password signs in and must still be changed; on a later node of a cluster it says that the administrator already exists.
Options
| Option | Meaning |
|---|---|
--binary FILE | the structam binary to install |
--public-url URL | the https:// URL agents and browsers use; required for every role |
--database-url-file FILE | a file holding the PostgreSQL connection string |
--local-postgres | install and use the distribution's PostgreSQL on this host |
--role serve or --role worker | cluster nodes (high availability); a worker takes the same --public-url and --trusted-proxies as the serve nodes |
--listen ADDR | default 127.0.0.1:8080 (127.0.0.1:8081 for a worker): a reverse proxy on the same host; use :8080 behind a load balancer elsewhere |
--trusted-proxies LIST | the proxy or load balancer addresses, default 127.0.0.1,::1 |
--secret-key-file FILE | the cluster's key, on every node after the first |
--replace-secret-key | change the key on purpose (rotating the secret key) |
--migrate | run the schema migrations on a node whose role does not by default |
--no-start | install without starting |
--dry-run | print what it would do and change nothing |
--uninstall | remove the units and the binary; keep /etc/structam and the database |
--help lists them all.
Re-runs and the secret key
Re-running the installer is safe. An env file you edited is kept, and the installer writes its own rendering beside it as structam.env.new; the service is restarted only when the binary, a unit, a setting or a secret changed.
The secret key seals every stored credential, every configuration file content and the server identity that agents pin, and the host may hold its only copy. So a re-run whose --secret-key-file holds a different key than the installed /etc/structam/secrets/secret_key (a typo, another cluster's key) stops before it changes anything; passing the same key again is fine. To change the key on purpose, follow rotating the secret key and add --replace-secret-key: the installer keeps the old key as secret_key.previous-<time> and as secret_key_previous, names the latter as STRUCTAM_SECRET_KEY_PREVIOUS_FILE and restarts the node, so every value sealed with the old key still opens. Once every node has the new key, run structam rotate-secret-key once, on one node:
sudo sh -c 'set -a; . /etc/structam/structam.env; set +a; runuser -u structam -- structam rotate-secret-key'Then, on every node, delete /etc/structam/secrets/secret_key_previous and at once re-run the installer without --secret-key-file: it drops the line and restarts the node. Until then a restart of that node fails on the missing file. A second --replace-secret-key is refused while secret_key_previous exists, because the keyring holds one previous key only.
A reverse proxy on the same host
The installer opens no firewall port and installs no reverse proxy. With Caddy on the same host, using the Caddy configuration from the release archive:
sudo apt-get install caddy # or dnf install caddy (EPEL / COPR)
sudo cp deploy/caddy/Caddyfile /etc/caddy/Caddyfile
sudo systemctl edit caddy # [Service]
# Environment=STRUCTAM_SITE=structam.example.com
# Environment=STRUCTAM_UPSTREAMS=127.0.0.1:8080
# Environment=STRUCTAM_TLS_MODE=acme
sudo systemctl restart caddyThe Caddy configuration terminates TLS, balances over the nodes listed in STRUCTAM_UPSTREAMS with a health check on /readyz, passes the agent WebSocket, does not buffer event streams, and writes an access log without query strings. STRUCTAM_TLS_MODE is internal, acme or byo (it then reads /etc/caddy/tls/cert.pem and /etc/caddy/tls/key.pem).
The systemd units
| Unit | Runs |
|---|---|
structam-all.service | structam all: API, web UI, agent gateway and full worker pools (one node) |
structam-serve.service | structam serve (cluster) |
structam-worker.service | structam worker (cluster) |
structam-migrate.service | structam migrate, started by the installer and for upgrades |
The units run as the unprivileged structam user with no capabilities, a read-only file system, a system-call filter and the rest of systemd's sandboxing (systemd-analyze security structam-all rates it 1.4, "OK"). The stop timeout is 45 s, which covers the drain (stopping a node). Logs go to the journal:
journalctl -u structam-all -fA unit that fails 10 times in 5 minutes is not restarted again: fix the cause, then systemctl reset-failed structam-all. Waiting for an unreachable database is not a failure (the process stays up).
Questions the docs do not answer?
Ask the people who build Structam. Installation media and licences come from KazLabs.