Getting started
Set up Anvil: .test domains, ports 80 and 443, local HTTPS and terminal commands. Then add your first Laravel or Node.js projects, or uninstall.
Install Anvil first: Installation.
Each project folder Anvil serves is an application. It's named after its
folder, or the name you link it with: ~/Sites/shop is shop, at shop.test.
CLI commands that take <site> or --app take that name.
First run
The first window, Welcome to Anvil, lists three steps in order, each ticked once done:
- Set up Anvil › Set Up…: asks for your password once.
- Install PHP: PHP 8.5 unless you pick another (8.6 as a preview). No password.
- Add your projects folder › Add Folder…: each project in it becomes an application. Or create a new application.
Later, Set up Anvil in the title bar lists each missing step with its own button and says which one asks for your password:
- Set up Anvil:
.testdomains, ports 80 and 443 (macOS), the HTTPS certificate and the terminal commands, behind one password or administrator prompt. On Linux, only the terminal commands. - Install PHP: PHP 8.5 unless you pick another, while none is installed.
- Install Node.js: a long-term support Node.js, once an app needs it.
- Install Git: on Windows, through winget, while Git is missing.
Until Anvil is set up, an application's address is dimmed, with Needs setup beside it.
With the CLI:
anvil php install 8.4 # the first PHP installed becomes the default
anvil setupanvil setup downloads the web server and puts the terminal commands on your
PATH. On macOS it then prints one sudo sh -c '…' command that runs the
remaining system steps; on Windows it asks for administrator permission and
runs them itself. The certificate authority only exists after the first
anvil start, so trusting it is a second step. You need it only for
HTTPS.
On macOS, setup first says when another program already has what it takes
over, e.g. "Port 80 is used by nginx (/opt/homebrew/bin/nginx). Quit it so
.test addresses reach Anvil.", or that .test addresses already go to another
DNS server, whose .test sites stop working once setup replaces it. It doesn't
stop you.
PHP is optional for static sites and for applications with their own server
(Node.js, Python, Rust, Go, .NET). Install those languages with
anvil runtime install, e.g. anvil runtime install node 24. See each
language page.
What setup changes
On macOS; see On Windows and On Linux for the others.
Local domains
/etc/resolver/test sends *.test lookups to Anvil's DNS server on
127.0.0.1, port 5354. The file name is the domain suffix and the port is
dns_port (see Configuration). After changing either,
run setup again.
Standard ports
Without this step every address carries a port: http://<folder>.test:8080.
Setup installs the LaunchDaemon dev.anvil.ports. At every boot it loads pf
rules that forward 80 and 443 on 127.0.0.1 and ::1 to http_port and
https_port (8080 and 8443). The web server keeps running as your user.
/etc/pf.conf is not touched.
HTTPS certificate
The first anvil start creates a local certificate authority in
~/.anvil/data/caddy. Setup trusts it in the System keychain. If macOS refuses,
the app adds it to your login keychain instead, with a second password prompt.
anvil trust adds it to the login keychain only.
Terminal commands
~/.anvil/shims holds php, composer, laravel, forge, node, npm, npx, pnpm and anvil.
They run a copy of the CLI in ~/.anvil/bin, so moving or deleting Anvil.app doesn't break them;
with that copy gone too, each runs the one your PATH has without Anvil.
| Where | Version used |
|---|---|
| Inside an application's folder | That application's PHP and Node.js |
| Anywhere else | Default PHP; Node.js from the folder's .anvil.toml, .nvmrc or .node-version, else the newest installed |
php, composer and node don't fall back. If Anvil has no PHP or Node.js installed, they stop with
an error instead of running Homebrew's. laravel and forge run your own if your
PATH has one, else the one Settings › Languages › PHP installs; Anvil never
installs them by itself.
Setup adds this block to ~/.zshrc, and to ~/.bash_profile if it exists (on
Linux: ~/.bashrc, and ~/.zshrc if it exists):
# Anvil: php, composer, laravel and node follow each site's versions
export PATH="$HOME/.anvil/shims:$PATH"
# Anvil endanvil which php prints which php binary runs in the current folder.
On Windows
One administrator prompt does what setup needs:
- Local domains: a Name Resolution Policy rule sends
*.testlookups to Anvil's DNS server on 127.0.0.1, port 53. - Standard ports: not needed; the web server listens on 80 and 443 itself.
- HTTPS certificate: the local certificate authority goes into the
machine's Trusted Root store.
anvil trustadds it to your user's store instead, without administrator rights. - Terminal commands:
%USERPROFILE%\.anvil\shims, which includesanvil, is added to your user PATH. Open a new terminal afterwards.
Anvil keeps everything in %USERPROFILE%\.anvil. Settings › Performance
shows whether it and your projects are on a Dev Drive, which antivirus
scanning slows down less.
On Linux
Anvil starts on .localhost, so applications answer at
http://<folder>.localhost:8080 with no password prompt. anvil setup puts
the terminal commands on your PATH and says that .test addresses, ports 80
and 443 and HTTPS trust aren't available on Linux yet.
.localhost instead of .test
.localhost names need no resolver file. To switch:
anvil tld localhost # applications answer at http://<folder>.localhostOn macOS you still need setup's password prompt to drop :8080 and to trust
the HTTPS certificate. In the app: Settings › General › Advanced › Domain.
.test is the default on macOS and Windows; anvil tld test switches back.
Add applications and start
anvil park ~/Sites # every folder in ~/Sites becomes <folder>.test
anvil start # runs in the foreground; Ctrl-C stops itOr link a single folder: cd ~/code/shop && anvil link makes it shop.test.
In the app, use the sidebar's + button: Add Folder of Applications…
parks, Add Application Folder… links. A folder that is itself one project
isn't parked; the app offers Add It as One Application. While the app is open, it runs the web
server itself and anvil start refuses to run.
PHP and static applications answer right away. Node.js, Python, Go, Rust and
.NET applications run their own dev server: click Start in the Dev tab.
With the CLI alone, run anvil app autostart <site> true and restart
anvil start. Until the dev server runs, the address shows a "not running"
page. A Next.js application opens at <name>.localhost until you click
Use <name>.test in its Overview.
Anvil doesn't prepare an existing project. It doesn't run composer install,
and a Laravel project still needs its .env. Non-PHP applications need their
language installed in Anvil first. See the language pages, starting with
PHP.
In the app, New… (⌘N, or Ctrl+N on Windows and Linux) creates an application and serves it in one go:
HTTPS
New applications are HTTP only: Anvil makes no certificate for them and
https:// doesn't answer. Turn HTTPS on per application:
anvil https shop # https://shop.test; http://shop.test redirects there
anvil https shop --off # back to HTTP onlyRestart anvil start to apply. If the
certificate authority isn't trusted yet, run anvil setup
again (on macOS, also the command it prints). On Linux, HTTPS trust comes in a
later release.
In the app, use Use HTTPS in the application's right-click menu. A lock after
its name means HTTPS is on. Settings › General › Addresses › HTTPS for new
applications (https_default in Configuration) turns
it on for applications added from then on. Existing ones keep their setting.
Uninstall
- Quit the app or stop
anvil start. - Back up your service databases if you need them; they live in
~/.anvil. - Run
anvil uninstallto list what Anvil changed, thenanvil uninstall --yesto undo it. On macOS this removes the/etc/resolverfiles, thedev.anvil.portsdaemon and its rules, the certificate authority from the System keychain (password prompt) and login keychain, the PATH block, the login item and the app's folders in~/Library. On Windows: the Name Resolution Policy rule, the certificate, the PATH entry and the login item. Everywhere,~/.anvil. Your projects are not touched. - Remove the app or CLI:
- macOS: delete
Anvil.appfrom/Applications. - Windows: remove Anvil in Settings › Apps.
- Linux: delete the AppImage, or remove the Anvil package with apt.
- Homebrew:
brew uninstall --cask anvil(the app) orbrew uninstall --formula anvil(the CLI alone). - Built from source:
cargo uninstall anvil.
- macOS: delete
By hand on macOS
If anvil no longer runs (the app was deleted first), undo the same steps
yourself, in this order: the certificate is read from ~/.anvil. A command
that finds nothing to remove says so; go on with the next.
# Certificate authority: login keychain, then System keychain
root=~/.anvil/data/caddy/pki/authorities/local/root.crt
sha1=$(openssl x509 -noout -fingerprint -sha1 -in "$root" | cut -d= -f2 | tr -d :)
security delete-certificate -Z "$sha1" -t ~/Library/Keychains/login.keychain-db
sudo security remove-trusted-cert -d "$root"
sudo security delete-certificate -Z "$sha1" -t /Library/Keychains/System.keychain
# Ports 80 and 443
sudo launchctl bootout system/dev.anvil.ports
sudo rm -f /Library/LaunchDaemons/dev.anvil.ports.plist
sudo pfctl -a com.apple/anvil -F all
# Login item and the app's folders
rm -f ~/Library/LaunchAgents/Anvil.plist
rm -rf ~/Library/WebKit/dev.anvil.desktop ~/Library/Caches/dev.anvil.desktop \
~/Library/Application\ Support/dev.anvil.desktop \
~/Library/Saved\ Application\ State/dev.anvil.desktop.savedState \
~/Library/Preferences/dev.anvil.desktop.plist
# Anvil's home: services' data, runtimes, shims
rm -rf ~/.anvilThen:
- In
/etc/resolver, delete withsudo rmeach file that holds onlynameserver 127.0.0.1andport 5354(yourdns_port), one per domain suffix Anvil was set up for, e.g./etc/resolver/test. - In
~/.zshrcand~/.bash_profile, delete the lines from# Anvil: php, composer, laravel and node follow each site's versionsto# Anvil end, then open a new terminal.
Next
- Applications: what Anvil detects and how each type runs
- Services: MySQL, PostgreSQL, Redis, Mailpit and S3 storage
- The desktop app
Installation
Install Anvil on macOS, Windows or Linux as the desktop app or the CLI alone, with Homebrew, a download or a .deb, or build it from source.
System requirements
Anvil system requirements on macOS, Windows and Linux: supported versions, the tools to install, the ports it listens on and what setup asks permission for.