Installing PHP on macOS provides a maintained interpreter for local development, Composer workflows, one-off scripts, and compatibility checks without relying on Apple-managed or app-bundled runtimes.
On recent macOS releases, the practical package-managed path is Homebrew. The php formula installs the active CLI binary plus helpers such as php-fpm and php-config under the same Homebrew prefix, so version checks, extension work, and later web-stack setup all start from one managed runtime.
A working Homebrew setup is required before starting because current macOS releases no longer bundle PHP. Apple Silicon systems normally install Homebrew under /opt/homebrew, Intel systems under /usr/local, older unsupported macOS releases may need another package source or source build, and an older PHP binary earlier in PATH can still mask the new install until the shell environment is refreshed.
Related: Install Homebrew on macOS
$ brew --prefix /opt/homebrew
Apple Silicon Macs normally use /opt/homebrew. Intel Macs usually use /usr/local.
$ brew update
Homebrew often refreshes metadata automatically before brew install, but an explicit update surfaces tap or formula issues before the package transaction. If the refresh cannot reach the Homebrew API or taps, resolve that connectivity problem before continuing because the install step will fail for the same reason.
$ brew install php
If Homebrew reports that php is already installed and up-to-date, the runtime is already present and the next verification step can be used immediately. The unversioned php formula tracks the newest maintained branch, while versioned formulae such as php@8.4 and php@8.3 stay available separately for pinned project requirements.
$ brew list --versions php php 8.5.4
The output shows the formula name and the installed package version. If it is empty, the install did not complete in the current Homebrew prefix.
$ php -v
PHP 8.5.4 (cli) (built: Mar 10 2026 23:15:23) (NTS)
Copyright (c) The PHP Group
Built by Homebrew
Zend Engine v4.5.4, Copyright (c) Zend Technologies
with Zend OPcache v8.5.4, Copyright (c), by Zend Technologies
The first line confirms the active version and the cli SAPI. Build timestamps and extension lines vary by formula revision and architecture.
Related: Check PHP version
$ type -a php php is /usr/local/bin/php php is /opt/homebrew/bin/php
The first match is the command the shell runs. On some Apple Silicon Macs, an older /usr/local/bin/php symlink can still appear ahead of the canonical /opt/homebrew/bin/php path, so review and remove or reorder that older entry if it shadows the intended Homebrew runtime.
$ php --ini Configuration File (php.ini) Path: "/opt/homebrew/etc/php/8.5" Loaded Configuration File: "/opt/homebrew/etc/php/8.5/php.ini" Scan for additional .ini files in: "/opt/homebrew/etc/php/8.5/conf.d" Additional .ini files parsed: (none)
Homebrew installs php-fpm and the matching php-fpm.ini tree with the same formula, but a background service is only necessary when a local web server or socket-based workflow will use that FastCGI runtime. Start it later with brew services start php only when it is actually needed.
Related: Find PHP configuration files