caddyscript

Source Code (v2 - Updated)

We believe in radical transparency. Below is the full source code for caddyscript v2.0 (Nov 2025).

It creates sites, manages users, handles backups, and performs clean uninstalls.

caddyscript.sh (14KB)
SHA256: Verification recommended after download.

What the script actually does (high-level)

  1. Checks you're root + running Debian 13
  2. Installs Caddy from official repo (auto-HTTPS + HTTP/3)
  3. Adds Sury PHP 8.3 + FPM with modern extensions
  4. Installs & secures MariaDB
  5. Sets up UFW (22,80,443 only), Fail2Ban, unattended-upgrades
  6. Creates per-site PHP-FPM pool + Caddyfile snippet
  7. Downloads & configures ClassicPress (or static site)
  8. Enables security headers, Zstd, immutable caching
  9. Optionally backs up with --backup tar/rsync
  10. Full uninstall with --uninstall
Usage: $ caddyscript [--install | --create --domain example.com --type static|classicpress|php | --delete example.com | --uninstall]

Dependencies Installed: caddy, php8.3-fpm, mariadb-server, ufw, zip, curl.

Usage (V2 - Command Line Interface)

Save as `/usr/local/bin/caddyscript`, `chmod +x`, and use like:
$ caddyscript --domain blog.com --type classicpress 
$ caddyscript --domain static.com --type static
$ caddyscript --domain staging.blog.com --type staging --staging-source blog.com
$ caddyscript --uninstall # nuclear cleanup