Skip to content

Deploying OpenProject Community Edition on Ubuntu 22.04 (production-ready)

Stand up a hardened OpenProject CE on Ubuntu 22.04 — PostgreSQL backend, Memcached, OIDC auth via Keycloak, nginx + Let's Encrypt, daily encrypted backups.

You’re rolling OpenProject Community Edition out as the program-management hub for engineering, design, and the PMO. The DEB package installer is straightforward, the first project is spun up by Friday afternoon, two thousand work packages are imported from Jira over the weekend, and Monday morning the engineering leads can’t sign in because the local user list still has only three accounts. The “we’ll point Keycloak at it later” item is still sitting in the migration backlog, attachments are landing on the same disk as the PostgreSQL data directory, and the configuration wizard accepted the embedded PostgreSQL it shipped with rather than the managed PG cluster on your private network. Six weeks later a routine vacuum runs hot, attachments-upload latency triples, and nobody can tell whether the issue is in the database, in Memcached, or in the Puma worker count because everything was deployed under the same root user with the defaults the installer chose.

What’s happening

OpenProject Community Edition on a single Ubuntu host needs four moving parts wired correctly or it falls over in production. PostgreSQL has to be a real instance — either on the host with proper tuning or on your existing managed cluster — never the embedded one the installer offers. Attachments live on a dedicated volume with its own backup policy, not on /var/db/openproject next to the WAL files. Memcached fronts the Rails cache so session lookups and project tree traversals don’t hit Postgres for every page render. Authentication should land on your IdP via OpenID Connect on day one; the built-in user table is fine for the four admins who bootstrapped the system and an active liability the moment HR onboards the first cohort that expects SSO. Background jobs run under their own systemd target, sized to the number of CPU cores you actually have. The DEB installer ships a configure script that lets you set all of this declaratively — but only if you know what to feed it. Defaults give you a working system that won’t survive scale.

How to verify

The OpenProject service should be listening only on the loopback after install:

ss -lntp | grep -E ':(80|443|6000|5432|11211)\b'
# 0.0.0.0:443  nginx
# 127.0.0.1:6000  openproject (apache2 wrapped by openproject package)
# 127.0.0.1:11211 memcached
# 127.0.0.1:5432 postgres

PostgreSQL and Memcached must not be reachable from the public NIC. The OpenProject configuration should show the OIDC provider attached:

sudo openproject config:get OPENPROJECT_OPENID__CONNECT_KEYCLOAK_HOST
sudo openproject config:get OPENPROJECT_OPENID__CONNECT_KEYCLOAK_DISPLAY__NAME

The HTTPS endpoint should return the login page with a “Sign in with Keycloak” button rendered:

curl -sS https://op.example.com/login | grep -E 'openid_connect|Keycloak' || echo "OIDC not visible"

Background workers should be active:

systemctl status openproject-web openproject-worker
sudo openproject run good_job dashboard | head -20

If any of those report missing, no jobs run and email notifications, attachment thumbnailing, and PDF export silently queue forever. Attachment storage should sit on its own volume:

findmnt /var/lib/openproject/attachments
# TARGET                            SOURCE  FSTYPE OPTIONS
# /var/lib/openproject/attachments  /dev/sdb1  ext4  rw,noatime

If the source is the same as /, your attachments and database compete for IOPS — fix it before the file collection exceeds a few gigabytes.

The fix

Save the script below as /root/setup-openproject-ubuntu22.sh, then run it. It installs OpenProject Community Edition on a fresh Ubuntu 22.04 VM via the official DEB package: base hardening (UFW, SSH key-only, fail2ban, unattended-upgrades), PostgreSQL 16 on the host bound to the loopback, Memcached for the Rails cache, OpenProject 14 from the official repository, a configuration pass that wires OIDC against Keycloak, attachments on a dedicated /var/lib/openproject/attachments mount, nginx in front of OpenProject’s bundled apache2 with Let’s Encrypt, daily encrypted backups to a separate path your VM-level backup can pick up, and a wait-loop on the OpenProject service.

#!/usr/bin/env bash
set -euo pipefail

### Ubuntu 22.04 OpenProject Community Edition installer
### Postgres 16 on the host, OIDC via Keycloak, attachments on dedicated volume
### Keeps root SSH key login enabled
### Disables SSH password login
### Enables automatic security updates
### No local backups beyond the daily dump; assumes VM-level backup
### Reboot remains manual

if [[ "$(id -u)" -ne 0 ]]; then
  echo "Run as root."
  exit 1
fi

: "${OPENPROJECT_DOMAIN:?Set OPENPROJECT_DOMAIN=op.example.com}"
: "${OPENPROJECT_EMAIL:?Set OPENPROJECT_EMAIL=ops@example.com for Let's Encrypt}"
: "${KEYCLOAK_HOST:?Set KEYCLOAK_HOST=auth.example.com}"
: "${KEYCLOAK_REALM:?Set KEYCLOAK_REALM=corp}"
: "${KEYCLOAK_CLIENT_ID:?Set KEYCLOAK_CLIENT_ID=openproject}"
: "${KEYCLOAK_CLIENT_SECRET:?Set KEYCLOAK_CLIENT_SECRET=...}"

ATTACHMENT_DEVICE="${ATTACHMENT_DEVICE:-/dev/sdb1}"
OPENPROJECT_VERSION="${OPENPROJECT_VERSION:-14}"
PG_PASSWORD="${PG_PASSWORD:-$(openssl rand -hex 24)}"
SECRET_KEY_BASE="${SECRET_KEY_BASE:-$(openssl rand -hex 64)}"

echo
echo "========================================"
echo "OpenProject CE Ubuntu 22.04 Setup"
echo "========================================"
echo

echo "==> Updating base OS"
export DEBIAN_FRONTEND=noninteractive
apt-get update
apt-get -y upgrade

echo "==> Installing base packages"
apt-get -y install \
  vim curl wget ca-certificates gnupg2 lsb-release apt-transport-https \
  chrony fail2ban unattended-upgrades \
  ufw lsof tcpdump dnsutils tar gzip xz-utils \
  iproute2 net-tools openssl jq age \
  software-properties-common

echo "==> Enabling time sync"
systemctl enable --now chrony
timedatectl set-ntp true

echo "==> Applying kernel/network tuning"
cat > /etc/sysctl.d/99-openproject.conf <<'SYSCTL'
net.core.default_qdisc = fq
net.ipv4.tcp_congestion_control = bbr

net.core.somaxconn = 4096
net.core.netdev_max_backlog = 250000
net.ipv4.tcp_max_syn_backlog = 8192
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_fin_timeout = 15
net.ipv4.ip_local_port_range = 10240 65535

net.ipv4.conf.all.accept_redirects = 0
net.ipv4.conf.default.accept_redirects = 0
net.ipv4.conf.all.send_redirects = 0

vm.swappiness = 10
vm.overcommit_memory = 1
kernel.dmesg_restrict = 1
kernel.kptr_restrict = 2
fs.file-max = 2097152
SYSCTL

modprobe tcp_bbr || true
echo tcp_bbr > /etc/modules-load.d/bbr.conf
sysctl --system

echo "==> Setting file limits"
cat > /etc/security/limits.d/99-openproject.conf <<'LIMITS'
* soft nofile 64000
* hard nofile 64000
root soft nofile 64000
root hard nofile 64000
openproject soft nofile 64000
openproject hard nofile 64000
LIMITS

echo "==> Configuring UFW"
ufw --force reset
ufw default deny incoming
ufw default allow outgoing
ufw allow 22/tcp
ufw allow 80/tcp
ufw allow 443/tcp
ufw --force enable

echo "==> Hardening SSH"
cp /etc/ssh/sshd_config /etc/ssh/sshd_config.bak.$(date +%F-%H%M%S)

set_sshd_option() {
  local key="$1"
  local value="$2"
  if grep -qE "^[#[:space:]]*${key}[[:space:]]+" /etc/ssh/sshd_config; then
    sed -i "s|^[#[:space:]]*${key}[[:space:]].*|${key} ${value}|" /etc/ssh/sshd_config
  else
    echo "${key} ${value}" >> /etc/ssh/sshd_config
  fi
}

set_sshd_option PermitRootLogin prohibit-password
set_sshd_option PasswordAuthentication no
set_sshd_option PubkeyAuthentication yes
set_sshd_option KbdInteractiveAuthentication no
set_sshd_option ChallengeResponseAuthentication no
set_sshd_option X11Forwarding no
set_sshd_option ClientAliveInterval 300
set_sshd_option ClientAliveCountMax 2
set_sshd_option MaxAuthTries 4

sshd -t
systemctl restart ssh

echo "==> Configuring fail2ban"
mkdir -p /etc/fail2ban/jail.d
cat > /etc/fail2ban/jail.d/sshd.local <<'FAIL2BAN'
[sshd]
enabled = true
port = ssh
backend = systemd
maxretry = 4
findtime = 10m
bantime = 1h
FAIL2BAN
systemctl enable --now fail2ban

echo "==> Configuring unattended-upgrades"
cat > /etc/apt/apt.conf.d/20auto-upgrades <<'AUTOUPG'
APT::Periodic::Update-Package-Lists "1";
APT::Periodic::Unattended-Upgrade "1";
APT::Periodic::AutocleanInterval "7";
AUTOUPG

echo "==> Mounting attachments volume"
if blkid "${ATTACHMENT_DEVICE}" >/dev/null 2>&1; then
  echo "Attachment device already formatted; skipping mkfs."
else
  mkfs.ext4 -L openproject-attach "${ATTACHMENT_DEVICE}"
fi
mkdir -p /var/lib/openproject/attachments
ATTACH_UUID=$(blkid -s UUID -o value "${ATTACHMENT_DEVICE}")
grep -q "${ATTACH_UUID}" /etc/fstab || \
  echo "UUID=${ATTACH_UUID} /var/lib/openproject/attachments ext4 defaults,noatime 0 2" >> /etc/fstab
mount -a

echo "==> Installing PostgreSQL 16"
install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://www.postgresql.org/media/keys/ACCC4CF8.asc \
  | gpg --dearmor -o /etc/apt/keyrings/postgres.gpg
echo "deb [signed-by=/etc/apt/keyrings/postgres.gpg] https://apt.postgresql.org/pub/repos/apt jammy-pgdg main" \
  > /etc/apt/sources.list.d/pgdg.list
apt-get update
apt-get -y install postgresql-16 postgresql-contrib-16

systemctl enable --now postgresql

sudo -u postgres psql <<SQL
CREATE USER openproject WITH PASSWORD '${PG_PASSWORD}';
CREATE DATABASE openproject OWNER openproject ENCODING 'UTF8' LC_COLLATE 'en_US.UTF-8' LC_CTYPE 'en_US.UTF-8' TEMPLATE template0;
SQL

# Force loopback-only Postgres
sed -i "s/^#\?listen_addresses.*/listen_addresses = 'localhost'/" /etc/postgresql/16/main/postgresql.conf
sed -i "s/^#\?password_encryption.*/password_encryption = scram-sha-256/" /etc/postgresql/16/main/postgresql.conf
systemctl restart postgresql

echo "==> Installing Memcached"
apt-get -y install memcached
sed -i 's/^-l .*/-l 127.0.0.1/' /etc/memcached.conf
sed -i 's/^-m .*/-m 512/' /etc/memcached.conf
systemctl restart memcached
systemctl enable memcached

echo "==> Adding OpenProject repository"
wget -O /etc/apt/trusted.gpg.d/openproject.asc https://dl.packager.io/srv/opf/openproject/key
wget -O /etc/apt/sources.list.d/openproject.list \
  "https://dl.packager.io/srv/opf/openproject/stable/${OPENPROJECT_VERSION}/installer/ubuntu/22.04.repo"
apt-get update
apt-get -y install openproject

echo "==> Configuring OpenProject (non-interactive)"
cat > /etc/openproject/installer.dat <<EOF
openproject/edition	select	standard
openproject/hostname	string	${OPENPROJECT_DOMAIN}
openproject/server_protocol	select	https
openproject/server_port	string	443
openproject/server_path_prefix	string	/
openproject/database_autoinstall	select	skip
openproject/database_hostname	string	127.0.0.1
openproject/database_port	string	5432
openproject/database_name	string	openproject
openproject/database_username	string	openproject
openproject/database_password	password	${PG_PASSWORD}
openproject/memcached_autoinstall	select	skip
openproject/memcached_hostname	string	127.0.0.1
openproject/memcached_port	string	11211
openproject/web_server	select	apache2
openproject/ssl_autoinstall	select	skip
openproject/letsencrypt_autoinstall	select	skip
openproject/svn_server	select	skip
openproject/git_server	select	skip
openproject/attachments_storage	select	local
openproject/attachments_storage_path	string	/var/lib/openproject/attachments
EOF

chmod 600 /etc/openproject/installer.dat
openproject configure --auto-answer

echo "==> Wiring OIDC against Keycloak"
openproject config:set OPENPROJECT_OPENID__CONNECT_KEYCLOAK_DISPLAY__NAME="Keycloak"
openproject config:set OPENPROJECT_OPENID__CONNECT_KEYCLOAK_HOST="${KEYCLOAK_HOST}"
openproject config:set OPENPROJECT_OPENID__CONNECT_KEYCLOAK_PORT="443"
openproject config:set OPENPROJECT_OPENID__CONNECT_KEYCLOAK_SCHEME="https"
openproject config:set OPENPROJECT_OPENID__CONNECT_KEYCLOAK_IDENTIFIER="${KEYCLOAK_CLIENT_ID}"
openproject config:set OPENPROJECT_OPENID__CONNECT_KEYCLOAK_SECRET="${KEYCLOAK_CLIENT_SECRET}"
openproject config:set OPENPROJECT_OPENID__CONNECT_KEYCLOAK_AUTHORIZATION__ENDPOINT="/realms/${KEYCLOAK_REALM}/protocol/openid-connect/auth"
openproject config:set OPENPROJECT_OPENID__CONNECT_KEYCLOAK_TOKEN__ENDPOINT="/realms/${KEYCLOAK_REALM}/protocol/openid-connect/token"
openproject config:set OPENPROJECT_OPENID__CONNECT_KEYCLOAK_USERINFO__ENDPOINT="/realms/${KEYCLOAK_REALM}/protocol/openid-connect/userinfo"
openproject config:set OPENPROJECT_OPENID__CONNECT_KEYCLOAK_END__SESSION__ENDPOINT="/realms/${KEYCLOAK_REALM}/protocol/openid-connect/logout"
openproject config:set OPENPROJECT_OPENID__CONNECT_KEYCLOAK_ISSUER="https://${KEYCLOAK_HOST}/realms/${KEYCLOAK_REALM}"
openproject config:set OPENPROJECT_SECRET__KEY__BASE="${SECRET_KEY_BASE}"
openproject config:set OPENPROJECT_HSTS="true"
openproject config:set OPENPROJECT_DISABLE__PASSWORD__LOGIN="true"
openproject config:set OPENPROJECT_SELF__REGISTRATION="0"

systemctl restart openproject-web openproject-worker

echo "==> Installing nginx + certbot"
apt-get -y install nginx certbot python3-certbot-nginx

cat > /etc/nginx/sites-available/openproject <<NGINX
upstream openproject_backend {
    server 127.0.0.1:6000;
    keepalive 32;
}

server {
    listen 80;
    listen [::]:80;
    server_name ${OPENPROJECT_DOMAIN};
    return 301 https://\$host\$request_uri;
}

server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;
    server_name ${OPENPROJECT_DOMAIN};

    client_max_body_size 256M;
    proxy_read_timeout   600s;
    proxy_send_timeout   600s;
    proxy_connect_timeout 60s;

    add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
    add_header X-Content-Type-Options nosniff always;
    add_header X-Frame-Options SAMEORIGIN always;
    add_header Referrer-Policy strict-origin-when-cross-origin always;

    location / {
        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 \$scheme;
        proxy_http_version 1.1;
        proxy_pass http://openproject_backend;
    }
}
NGINX

ln -sf /etc/nginx/sites-available/openproject /etc/nginx/sites-enabled/openproject
rm -f /etc/nginx/sites-enabled/default

nginx -t
systemctl enable --now nginx
systemctl reload nginx

echo "==> Requesting Let's Encrypt certificate"
certbot --nginx --non-interactive --agree-tos \
  -m "${OPENPROJECT_EMAIL}" -d "${OPENPROJECT_DOMAIN}" --redirect

systemctl enable --now certbot.timer

echo "==> Installing daily encrypted backup job"
mkdir -p /var/backups/openproject
chmod 700 /var/backups/openproject

age-keygen -o /etc/openproject/backup.key
chmod 600 /etc/openproject/backup.key
BACKUP_RECIPIENT=$(grep '# public key:' /etc/openproject/backup.key | awk '{print $4}')

cat > /usr/local/sbin/openproject-backup.sh <<EOF
#!/usr/bin/env bash
set -euo pipefail
TS=\$(date +%F-%H%M)
DEST=/var/backups/openproject
sudo -u postgres pg_dump -Fc openproject \\
  | age -r ${BACKUP_RECIPIENT} > "\${DEST}/openproject-\${TS}.dump.age"
tar -czf - -C /var/lib/openproject attachments \\
  | age -r ${BACKUP_RECIPIENT} > "\${DEST}/openproject-attachments-\${TS}.tar.gz.age"
find "\${DEST}" -name 'openproject-*' -mtime +14 -delete
EOF
chmod 700 /usr/local/sbin/openproject-backup.sh

cat > /etc/systemd/system/openproject-backup.service <<'EOF'
[Unit]
Description=OpenProject encrypted backup
After=postgresql.service openproject-web.service

[Service]
Type=oneshot
ExecStart=/usr/local/sbin/openproject-backup.sh
EOF

cat > /etc/systemd/system/openproject-backup.timer <<'EOF'
[Unit]
Description=Daily OpenProject backup

[Timer]
OnCalendar=*-*-* 03:25:00
RandomizedDelaySec=900
Persistent=true

[Install]
WantedBy=timers.target
EOF

systemctl daemon-reload
systemctl enable --now openproject-backup.timer

echo "==> Waiting for OpenProject"
for i in {1..120}; do
  if curl -fsSL "http://127.0.0.1:6000" -H "Host: ${OPENPROJECT_DOMAIN}" >/dev/null 2>&1; then
    break
  fi
  sleep 2
done

systemctl is-active openproject-web openproject-worker

echo "==> Final package update"
apt-get -y upgrade

echo
echo "========================================"
echo "DONE"
echo "========================================"
echo
echo "Listeners:"
ss -lntp | grep -E ':(80|443|5432|6000|11211)\b' || true

echo
echo "SSH effective settings:"
sshd -T | grep -E '^(permitrootlogin|passwordauthentication|pubkeyauthentication) ' || true

echo
echo "OpenProject services:"
systemctl is-active openproject-web openproject-worker postgresql memcached nginx

echo
echo "OIDC config:"
openproject config:get OPENPROJECT_OPENID__CONNECT_KEYCLOAK_ISSUER

echo
echo "Backup recipient (keep this!):"
echo "${BACKUP_RECIPIENT}"
echo
echo "Web UI:"
echo "https://${OPENPROJECT_DOMAIN}/"
echo
echo "First steps:"
echo "1. Open the URL — log in via Keycloak as a user that belongs to the admin group in Keycloak."
echo "2. Promote that user to OpenProject admin via 'openproject run rails runner \"User.find_by(login: \\\"<login>\\\").update(admin: true)\"'."
echo "3. Disable any remaining local user signup paths under Administration -> Authentication."

Make it executable and run it:

chmod 700 /root/setup-openproject-ubuntu22.sh
OPENPROJECT_DOMAIN=op.example.com \
OPENPROJECT_EMAIL=ops@example.com \
KEYCLOAK_HOST=auth.example.com \
KEYCLOAK_REALM=corp \
KEYCLOAK_CLIENT_ID=openproject \
KEYCLOAK_CLIENT_SECRET=$(cat /root/.kc-openproject.secret) \
ATTACHMENT_DEVICE=/dev/sdb1 \
/root/setup-openproject-ubuntu22.sh

The first Keycloak sign-in lands a user in OpenProject with member-level permissions; promote that account to admin via the Rails runner one-liner the script prints. Once you have one admin in place, walk through Administration -> Authentication and confirm “Self-registration” is set to “disabled”, the OIDC provider shows up under “Authentication modes”, and OPENPROJECT_DISABLE__PASSWORD__LOGIN=true is in effect — that combination forces every new user through Keycloak and removes the local username/password fallback that’s a common audit finding. Confirm the daily backup timer fires once before you call it done: systemctl start openproject-backup.service and check the encrypted dump lands in /var/backups/openproject/. Keep the age private key (/etc/openproject/backup.key) somewhere off this host — without it, the backups are unreadable.

For an OpenProject tier you don’t have to operate yourself, run it on our managed cloud compute with patching, monitoring, and Sev-1 escalation in place — or start a scoping call if you’d like us to plan the rollout and IdP wiring.