Local WordPress development on Docker. camp gives each site a plain compose.yaml (nginx, PHP-FPM,
MariaDB or MySQL, Redis, Mailpit, phpMyAdmin) on prebuilt images, and a short command for everything you
do with it: start, stop, WP-CLI, imports, backups, Xdebug. Nothing is hidden or generated behind your
back: the site's compose.yaml is an ordinary file in the site, and plain docker compose works too.
Needs Docker and git (xcode-select --install). OrbStack is recommended:
it gives every site an HTTPS hostname (https://mysite.orb.local, with mail. and pma. next to
it). Docker Desktop, Colima and the like work too; sites are then plain http://localhost:<port>.
camp checks which one is running when it creates a site. Then, once per Mac:
curl -fsSL https://raw.githubusercontent.com/builtnorth/camp/main/install.sh | shThis downloads camp to ~/.camp, makes the camp command (a link in ~/.local/bin), and adds
~/.local/bin to your PATH in ~/.zshrc if needed. It needs no admin password, and running it again
updates camp. You can read install.sh first; it's short.
camp writes the environment (compose.yaml and .env); the code comes from a source you pick. Run it
in the folder that should hold the site:
camp new mysite # plain WordPress
camp new mysite --source git@github.com:you/starter.git # a starter repo (your own git access)
camp new mysite --source ~/starters/agency # a starter folder
camp new mysite --source composer:roots/bedrock # a Composer project, e.g. Bedrock
camp new --source . # this folder, already set up by another toolThen camp:
- Keeps the source's own
compose.yamlif it has one, giving it this site's name and three free ports. Otherwise writes one for the code's layout, found from where WordPress is: the standard layout (WordPress at the top of the folder, as a plain site fromcamp newgets), Bedrock (web/, core in/wp), core in a subfolder such aspublic/app, and so on. For code whose WordPress Composer installs later, camp readswordpress-install-dirfromcomposer.json. Anything else:--webroot <folder>(what nginx serves) and--core <url path>(empty when core is in that folder). - Writes
.envfrom the source's.env.example(or camp's), with the site's address and a new database. With OrbStack the address ishttps://mysite.orb.local; without it,http://localhost:<port>(andSITE_HTTPS=off).--hostsets a hostname of your own, andCAMP_ORBSTACK=1or0overrides the check. - Starts the site, fills in the passwords and salts, runs
composer installif there's acomposer.json, downloads WordPress for a plain site, and installs it. - Runs the source's
post-newhook, if it has one (see Hooks). - Prints the admin login. A new folder is a fresh git repo with no commits.
Run them in a site's folder, or any folder inside it:
| Command | What it does |
|---|---|
camp up |
Start the site. The first time, fills in the blank passwords and salts in .env |
camp down |
Export the database to backups/db.sql.gz, then stop. The database is kept |
camp backup |
Export the database to backups/db.sql.gz. --if-running skips a stopped site |
camp logs [service] |
Follow the logs of every container, or one: web, php, db, redis, mail, pma |
camp shell [command] |
A shell in the PHP container, or one command: camp shell 'php -v' |
camp wp … |
WP-CLI: camp wp plugin list |
camp composer … |
Composer: camp composer require vendor/package |
camp xdebug on / off |
Switch Xdebug live, without a restart. Trigger mode: a session starts only when your IDE or the Xdebug browser extension asks. Off again when the container is recreated |
camp import <dump> [--from <url>] |
Import a .sql or .sql.gz dump (e.g. from the live site). Saves the current database to backups/ first, reads the dump's site URL (or --from) and replaces it with this site's URL. A dump that fails halfway is rolled back |
camp update |
Update camp itself. In a site, also download its newer images (the weekly rebuilds) and restart it on them if it's running |
Once .env has its passwords (after the first camp up, or filled in by hand), a site also runs with
plain docker compose. camp only shortens the commands.
PHP_VERSION=8.1 camp up # PHP 7.4, 8.0, 8.1, 8.2, 8.3, 8.4 or 8.5
DB_TYPE=mysql DB_VERSION=8.4 camp up # MySQL instead of MariaDB
camp up # back to the site's defaults (in compose.yaml)Each database engine keeps its own data, so switching back finds it unchanged.
A site, or a starter, can carry a .camp/ folder:
| File | What camp does with it |
|---|---|
.camp/hooks/post-new |
runs once, after camp new has created and installed the site (rename a theme, activate plugins, …) |
.camp/hooks/post-up |
runs after every camp up |
.camp/hooks/post-import |
runs after camp import (deactivate production-only plugins, add a local admin, …) |
.camp/secrets |
more .env names for camp to fill with random values, one per line, besides the database passwords and WordPress's salts |
Hooks are executable files (any language), run on your Mac in the site's folder, with CAMP_EVENT,
CAMP_SITE_DIR and CAMP_SITE_NAME set. They can call camp themselves, e.g. camp wp theme activate ….
A failing hook stops camp with an error.
camp never replaces a value that's already set in .env, and treats generateme (Bedrock's
placeholder) as unset.
| Image | What it is |
|---|---|
ghcr.io/builtnorth/camp-php:<version> |
PHP-FPM, one tag per PHP version: 7.4, 8.0, 8.1, 8.2, 8.3, 8.4, 8.5 |
ghcr.io/builtnorth/camp-nginx:1 |
nginx with a WordPress config |
Both are public and built for Apple Silicon and Intel.
Built on the official PHP image. Every version has the same tools:
- Extensions: mysqli, pdo_mysql, gd (WebP, JPEG, FreeType; AVIF on PHP 8.1+), intl, zip, exif, opcache, bcmath, Redis, Imagick
- Xdebug, installed but off.
camp xdebug onswitches step debugging on (port 9003,host.docker.internal). Don't setXDEBUG_MODEon the service: it overrides that switch - WP-CLI and Composer, run as
www-data - Mail goes to the Compose service named
mailon port 1025 (Mailpit), through msmtp. Nothing leaves the machine - The MariaDB client, for WP-CLI's
dbcommands. It works with MariaDB and MySQL (seephp/mysql-client-wrapper.sh) - Local development PHP settings:
php/php.ini
The site's code is mounted at /var/www/html.
The official nginx image with a WordPress config (nginx/default.conf.template). Two settings on the
web service fit it to a site's layout:
| Setting | What it is | Default |
|---|---|---|
WEBROOT |
the folder nginx serves | /var/www/html/public |
WP_CORE_PATH |
WordPress core's URL path; /wp-admin and /wp-login.php redirect there |
/app (/wp for Bedrock, empty for core at the web root) |
SITE_HTTPS |
whether PHP is told the request was HTTPS: on behind OrbStack or a local HTTPS proxy, off for plain http://localhost |
on |
When the site folder is itself the web root, nginx refuses to serve the project files next to
WordPress: .env and other dotfiles, compose.yaml, composer.json/.lock, wp-cli.yml,
package.json, backups/, vendor/, node_modules/, and .sql/.log files.
PHP is expected at php:9000. HTTPS is handled in front of nginx (OrbStack, or a local proxy), so nginx
serves plain HTTP and tells PHP the request was HTTPS.
- GitHub Actions (
.github/workflows/build.yml) builds and publishes every image whenphp/,nginx/or the workflow change onmain, and rebuilds weekly from scratch so security fixes in the official base images get in. Pull requests build without publishing. Docs-only changes don't build. For a change that shouldn't rebuild (comments, say), put[skip ci]in the commit message body. - Dependabot opens a monthly PR bumping the GitHub Actions used by the build.
- Tool versions (WP-CLI, Xdebug, Redis, Imagick) are set at the top of
php/Dockerfileand bumped by hand. A WP-CLI bump also needs its new.sha512inWP_CLI_SHA512; the build fails until it matches.
Base images are the official images on Docker Hub (php, composer, nginx). The build doesn't log in:
GitHub's hosted runners aren't subject to Docker Hub's pull limit for public images
(GitHub docs). If a build ever fails with a
429 / toomanyrequests error anyway, add a docker/login-action step with a Docker Hub access token.
The last good images stay published meanwhile, so sites aren't affected.
Edit the files in php/ or nginx/ and push to main. Sites pick up the new image on their next
camp update. To try a change locally first:
docker build -t camp-php:8.4-local --build-arg PHP_VERSION=8.4 phpOlder PHP versions: 7.4 uses Xdebug 3.1 (the last release for it). 7.4 and 8.0 are on Debian 11, whose packages now come from archive.debian.org. These versions are for testing only; PHP itself no longer supports them.