Run it without Hafen
Quit Hafen first — that stops all services and frees the ports. Set two variables, then start what you need. Examples for PHP 8.6 on an Apple Silicon Mac.
Caddy & PHP-FPM
# the same two variables in every Terminal window
H="$HOME/Library/Application Support/Hafen"
B="$(brew --prefix)"
# web server, as Hafen starts it
caddy run --config "$H/Caddyfile" --adapter caddyfile
# one php-fpm per PHP version
"$B/opt/php@8.6/sbin/php-fpm" -F -y "$H/php/8.6/php-fpm.conf" -d xdebug.mode=off
Database & backup
M="$(echo "$H"/mysql-dist/*/bin)"
"$M/mysql" --no-defaults -uroot --socket="$H/run/mysql.sock"
"$M/mysqldump" --no-defaults -uroot --socket="$H/run/mysql.sock" \
--single-transaction --routines --triggers --events client | gzip -c > client.sql.gz
- Overwritten
- The
Caddyfile, httpd.conf, each php-fpm.conf, the Hafen block in /etc/hosts, projects.json and settings.json are rewritten whenever Hafen starts servers or you change something. Edits by hand only last until then — fine for a quick test followed by caddy reload.
- Yours
php.ini and conf.d of each PHP version, .htaccess, .user.ini, your project files, your databases and everything outside the Hafen block in /etc/hosts are never touched.
- PID files
- At launch Hafen ends every process still listed in a PID file in
run/ — also a database server or Apache you started yourself with Hafen’s configuration. Stop what you started by hand before you open Hafen again.
- brew services
- Homebrew’s services use their own configuration files, not Hafen’s, and Caddy as a service keeps its data elsewhere and creates a new certificate authority — trust its
root.crt again. Copy Hafen’s Caddyfile to etc/Caddyfile in the Homebrew prefix first.
- Hosts
- The
/etc/hosts block works on its own — leave it in place and the domains keep resolving without Hafen.