Skip to content

Deploying DirectAdmin on AlmaLinux 9 — full installer with CustomBuild and license activation

Stand up a production DirectAdmin server on AlmaLinux 9 from scratch — base hardening, the official setup.sh installer, CustomBuild for the web stack, license activation, and admin onboarding.

You buy a DirectAdmin license, fire up a fresh AlmaLinux 9 VM, and run setup.sh from the wiki. Twenty-five minutes later you have a panel that logs in. Then the operational reality starts: somebody points DNS at the box, customers begin to provision, you discover that the default install put MySQL on the root filesystem with no quota planning, the default Apache MPM is wrong for the hardware, and the license is locked to the original IP so changing IPs later means a license re-sync. DirectAdmin’s installer is small and well-tested. The work is everything around it.

What’s happening

DirectAdmin on AlmaLinux 9 is a single-server control panel — orchestrator and worker on the same box. Unlike Enhance, there is no separate control plane; the panel, the customer accounts, the web servers, mail, DNS, and MySQL all live on one server (or scale to multi-server with the DirectAdmin Cluster Mode but that’s an extension, not the default). The web stack is built by CustomBuild, DirectAdmin’s package manager for the underlying services. CustomBuild compiles or installs Apache, Nginx, PHP, MariaDB, Exim, Dovecot, and a list of optional pieces (ProFTPD/PureFTPD, ModSecurity, ConfigServer Firewall) based on an options.conf file you control.

The deployment is straightforward but has decision points that are easy to skip:

  • Web stack: Apache + mod_lsapi, Nginx + Apache (reverse proxy), Nginx-only with PHP-FPM, or LiteSpeed. Each has a different memory footprint and a different way of handling PHP. Apache + Nginx reverse proxy is the most common production choice — Nginx fronts static, Apache handles PHP via mod_lsapi.
  • PHP versions: CustomBuild lets you install up to four PHP versions side by side. Pick a current version (8.3) and one prior (8.2) at install time; you can add more later, but the customer-facing PHP selector in DirectAdmin shows what you’ve built.
  • Database: MariaDB by default, MySQL or Percona optional. Most operators stick with MariaDB. Put the data dir on its own LVM volume — a customer who fills up MySQL can otherwise fill the root filesystem and take the panel down with them.
  • Mail: Exim + Dovecot is the default. There’s no reasonable alternative — keep it.
  • Firewall: CSF (ConfigServer Firewall) is the de facto standard for DirectAdmin. Install it during the post-install hardening and configure the rules before exposing the panel to the internet.
  • License: DirectAdmin licenses are tied to the server IP. If you plan to change the IP later (e.g., move from a temp setup IP to the final public IP), do that before activating the license, or contact DirectAdmin support to re-sync.

How to verify

After install, the panel should answer on port 2222:

curl -sk https://<server-ip>:2222/ | head
# <html><head><title>DirectAdmin Login</title>...

systemctl status directadmin
# Active: active (running)

/usr/local/directadmin/directadmin v
# v1.66.x

The web stack should be running, with Apache + Nginx + PHP listening on the right ports:

ss -lntp | grep -E ':(80|443|8080|8081)\b'
# 80, 443 -> nginx
# 8080, 8081 -> apache (loopback only)

CustomBuild should report a clean state:

cd /usr/local/directadmin/custombuild
./build versions
./build versions_check
# All "OK" — no pending updates required before first use

The MySQL data dir should be on the dedicated volume, not on /:

df -h /var/lib/mysql
# /dev/mapper/data-mysql  100G  ...  /var/lib/mysql

If /var/lib/mysql is on the root filesystem, fix the storage layout before the first customer.

The fix

Save the script as /root/setup-directadmin.sh and run on a fresh AlmaLinux 9 VM. It does base hardening (SELinux permissive — required for DirectAdmin’s userland; fail2ban; dnf-automatic security only; SSH key-only on a non-default port if you prefer), kernel/sysctl tuning for a hosting workload, dedicated LVM volume for /var/lib/mysql, the official setup.sh installer with the right environment variables, CustomBuild post-install (Apache + Nginx reverse proxy, PHP 8.3 + 8.2, MariaDB 10.11, mod_security, ConfigServer Firewall), and license activation if the key is provided in advance.

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

### AlmaLinux 9 DirectAdmin installer
### Run as root on a fresh VM. Edit the variables below.

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

# === EDIT ===
HOSTNAME_FQDN="da.example.com"
ADMIN_EMAIL="ops@example.com"
LICENSE_CLIENT_ID=""        # DirectAdmin client ID (numeric)
LICENSE_KEY=""              # DirectAdmin license key
LICENSE_SERVER_IP=""        # public IP this license is bound to (or leave empty to auto-detect)
MYSQL_DEVICE="/dev/sdb"     # dedicated block device for MariaDB data
# ============

LICENSE_SERVER_IP="${LICENSE_SERVER_IP:-$(ip -4 -j route get 1.1.1.1 | jq -r '.[0].prefsrc')}"

echo
echo "========================================"
echo "DirectAdmin install on ${HOSTNAME_FQDN}"
echo "Public IP for license: ${LICENSE_SERVER_IP}"
echo "========================================"
echo

hostnamectl set-hostname "${HOSTNAME_FQDN}"

echo "==> Updating base OS"
dnf -y update
dnf -y install epel-release
dnf -y install vim curl wget chrony fail2ban dnf-automatic \
  policycoreutils-python-utils lsof tcpdump bind-utils \
  parted lvm2 xfsprogs jq tar quota \
  iproute net-tools

systemctl enable --now chronyd

echo "==> SELinux permissive (DirectAdmin userland requires)"
sed -i 's/^SELINUX=.*/SELINUX=permissive/' /etc/selinux/config
setenforce 0 || true

echo "==> Kernel/sysctl tuning for hosting workload"
cat > /etc/sysctl.d/99-directadmin.conf <<'SYSCTL'
vm.swappiness = 10
vm.overcommit_memory = 1
fs.file-max = 2097152
fs.inotify.max_user_watches = 524288
fs.inotify.max_user_instances = 8192
net.core.somaxconn = 8192
net.ipv4.tcp_max_syn_backlog = 8192
net.ipv4.tcp_syncookies = 1
net.ipv4.ip_local_port_range = 10240 65535
net.netfilter.nf_conntrack_max = 524288
kernel.dmesg_restrict = 1
SYSCTL
sysctl --system

cat > /etc/security/limits.d/99-directadmin.conf <<'LIMITS'
* soft nofile 200000
* hard nofile 200000
* soft nproc 65535
* hard nproc 65535
LIMITS

echo "==> Hardening SSH"
sed -i 's|^[#[:space:]]*PermitRootLogin.*|PermitRootLogin prohibit-password|' /etc/ssh/sshd_config
sed -i 's|^[#[:space:]]*PasswordAuthentication.*|PasswordAuthentication no|' /etc/ssh/sshd_config
sshd -t && systemctl restart sshd

echo "==> dnf-automatic for security updates"
cat > /etc/dnf/automatic.conf <<'DNFAUTO'
[commands]
upgrade_type = security
random_sleep = 900
download_updates = yes
apply_updates = yes
[emitters]
emit_via = stdio
DNFAUTO
systemctl enable --now dnf-automatic.timer

echo "==> Building dedicated LVM volume for MariaDB"
if [[ -b "${MYSQL_DEVICE}" ]] && ! mount | grep -q '/var/lib/mysql'; then
  parted -s "${MYSQL_DEVICE}" mklabel gpt
  parted -s "${MYSQL_DEVICE}" mkpart primary 0% 100%
  pvcreate -ff -y "${MYSQL_DEVICE}1"
  vgcreate data-vg "${MYSQL_DEVICE}1"
  lvcreate -l 100%FREE -n mysql-lv data-vg
  mkfs.xfs -f /dev/data-vg/mysql-lv
  mkdir -p /var/lib/mysql
  echo "/dev/data-vg/mysql-lv  /var/lib/mysql  xfs  defaults,noatime  0 2" >> /etc/fstab
  mount /var/lib/mysql
fi

echo "==> Pre-install: install build prerequisites"
dnf -y groupinstall "Development Tools"
dnf -y install gcc gcc-c++ make autoconf automake libtool \
  zlib-devel openssl-devel libxml2-devel \
  perl-libwww-perl perl-Mail-SPF \
  bind-utils

echo "==> Running DirectAdmin setup.sh"
mkdir -p /usr/local/directadmin
cd /usr/local/directadmin

# DirectAdmin official setup script. Pass license + email as env vars.
export DA_CHANNEL="stable"
export DA_SKIP_LICENSE_CHECK="no"
export DA_EMAIL="${ADMIN_EMAIL}"
export DA_HOSTNAME="${HOSTNAME_FQDN}"

if [[ -n "${LICENSE_CLIENT_ID}" && -n "${LICENSE_KEY}" ]]; then
  curl -fsSL https://download.directadmin.com/setup.sh -o /root/setup.sh
  chmod 700 /root/setup.sh
  echo "y" | bash /root/setup.sh "${LICENSE_CLIENT_ID}" "${LICENSE_KEY}" "${LICENSE_SERVER_IP}"
else
  echo "No license key provided. Setup will prompt you interactively."
  curl -fsSL https://download.directadmin.com/setup.sh -o /root/setup.sh
  chmod 700 /root/setup.sh
  bash /root/setup.sh
fi

echo "==> Configuring CustomBuild options"
cd /usr/local/directadmin/custombuild

# Pull current options and apply our hosting profile
./build update

# Set the web stack and PHP versions
./build set webserver nginx_apache
./build set apache_ver 2.4
./build set mariadb 10.11
./build set php1_release 8.3
./build set php1_mode lsapi
./build set php2_release 8.2
./build set php2_mode lsapi
./build set modsecurity yes
./build set modsecurity_ruleset comodo
./build set redis yes
./build set memcached yes
./build set exim yes
./build set dovecot yes
./build set imap yes
./build set pureftpd yes
./build set csf yes

./build save

echo "==> CustomBuild — first full build (this takes 20-40 minutes)"
./build update
./build all d

echo "==> Installing CSF firewall"
cd /usr/local/src
wget -q https://download.configserver.com/csf.tgz
tar -xzf csf.tgz
cd csf
sh install.sh

# CSF default config — open the right ports for DirectAdmin + hosting
sed -i 's/^TESTING = "1"/TESTING = "0"/' /etc/csf/csf.conf
sed -i 's/^TCP_IN = ".*"/TCP_IN = "22,25,53,80,110,143,443,465,587,993,995,2222,49152:65535"/' /etc/csf/csf.conf
sed -i 's/^UDP_IN = ".*"/UDP_IN = "53,80,443"/' /etc/csf/csf.conf

csf -r
systemctl enable --now csf
systemctl enable --now lfd

echo "==> fail2ban (in addition to CSF/LFD — covers app-level brute force)"
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 "==> Waiting for DirectAdmin to respond"
for i in {1..30}; do
  if curl -sk "https://${HOSTNAME_FQDN}:2222/" >/dev/null 2>&1; then
    echo "DirectAdmin responding."
    break
  fi
  sleep 4
done

echo
echo "========================================"
echo "DONE"
echo "========================================"
echo
echo "Panel: https://${HOSTNAME_FQDN}:2222/"
echo "Admin username: admin"
echo "Admin password is in /usr/local/directadmin/scripts/setup.txt"
echo
echo "Listeners:"
ss -lntp | grep -E ':(22|25|53|80|110|143|443|465|587|993|995|2222|8080)\b' || true
echo
echo "MySQL data dir:"
df -h /var/lib/mysql
echo
echo "Next steps:"
echo "  1. Log in to the panel, change the admin password"
echo "  2. Set up the first reseller and a customer package"
echo "  3. Configure DNS NS records to point to this server"
echo "  4. Run /usr/local/directadmin/custombuild/build all d again in 24h for second-pass tuning"

Make it executable and run:

chmod 700 /root/setup-directadmin.sh
/root/setup-directadmin.sh

After the install completes, log in to the panel at https://<your-fqdn>:2222/, change the admin password immediately (the default is in /usr/local/directadmin/scripts/setup.txt — read it once and rotate). Set up the first reseller and customer package before pointing DNS at the server. Set up CSF’s allow-list to include your admin IPs so a misconfigured CSF rule doesn’t lock you out — csf -a <your-ip> "admin". Test the customer experience end-to-end with one test account: create the account, provision a website, install WordPress through DirectAdmin’s installer, confirm TLS issues via Let’s Encrypt, and send/receive mail.

Run DirectAdmin under Managed Cloud Ops and we keep CustomBuild patched, the license tracked, and brute-force attempts escalated through monitoring and on-call — scope your DirectAdmin server and we will size the VM with you.