Updating PHP can feel daunting when you are not sure which installation your Mac is using. The original version of this article offered a quick way to replace an old macOS PHP installation. That workflow is no longer safe or current, so this reviewed version keeps the same practical goal while focusing on an existing Homebrew-managed command-line installation.
August 2026 technical review: The archived instructions used an abandoned third-party installer over unencrypted HTTP, an unsupported PHP 7.2 release, macOS-bundled Apache assumptions, Intel-only paths, and direct shell-profile edits with
sudo. Those steps have been removed. Use a currently supported PHP release and check the official documentation again before following time-sensitive package guidance.
What This Guide Updates
This page covers installing or updating Homebrew’s current unversioned php formula for command-line use. It does not switch between several installed PHP branches. For that separate task, see how to change PHP versions on a Mac.
It also does not reconfigure Apache, nginx, PHP-FPM, Laravel Valet, MAMP, XAMPP, or Docker. Those tools can use a different PHP executable and configuration from the one your shell resolves.
1. Inspect the Current Installation
Before changing anything, see what your shell is running:
php -v
command -v php
brew --version
If Homebrew is not installed, use the current instructions on the official Homebrew installation page. Do not copy an old installer command from an archived tutorial.
Check whether Homebrew currently manages the unversioned PHP formula:
brew list --versions php
brew info php
The first command reports the installed Homebrew version when the formula is present. brew info php shows the current formula details and caveats.
2. Confirm That the Target PHP Branch Is Supported
PHP release support changes over time. Review the official PHP supported-versions page before updating, especially for a machine used to develop or serve internet-facing applications.
As reviewed in August 2026, Homebrew’s unversioned php formula follows its current stable PHP release. That detail will change, so treat brew info php and the Homebrew PHP formula page as the current source of truth.
3. Install or Update Homebrew PHP
If Homebrew does not already manage the unversioned formula, install it with:
brew install php
If it is already installed, refresh Homebrew’s package information and upgrade that formula:
brew update
brew upgrade php
Read the proposed changes and any caveats shown by Homebrew. Do not use sudo with these package commands in a normal supported Homebrew installation.
4. Verify the Active CLI Executable
Refresh your shell’s command lookup and inspect PHP again:
hash -r
php -v
command -v php
brew --prefix php
brew --prefix php asks Homebrew for the formula’s location instead of assuming /opt/homebrew on Apple Silicon or /usr/local on Intel. If command -v php still points somewhere unexpected, review your shell’s PATH and the post-installation directions printed by Homebrew.
Homebrew’s installation documentation explains how brew shellenv configures the correct prefix for the shell you actually use. Follow those official directions deliberately rather than copying a hard-coded path or overwriting a profile file.
5. Check PHP Configuration
Confirm which configuration the active CLI executable loads:
php --ini
php -m
The first command reports the loaded php.ini and additional scan directories. The second lists enabled modules. An upgraded PHP branch may use a different configuration directory, so review the output instead of assuming an old file was carried forward.
CLI PHP and Web-Server PHP Are Separate
Seeing the expected result from php -v proves only which executable the current shell runs. A web server, PHP-FPM service, local development application, or container can use another PHP installation and another php.ini.
If a browser still reports a different version, inspect that environment’s own configuration and consult its current documentation. This article intentionally avoids automatic Apache edits and service restarts because the correct action depends on the web stack installed on that Mac.
Guidance to Recheck Periodically
The following details are time-sensitive and should be verified before reuse:
- which PHP branches still receive security fixes;
- which PHP release the unversioned Homebrew formula installs;
- which versioned PHP formulae Homebrew currently offers;
- which macOS and processor combinations Homebrew supports; and
- the formula caveats, service instructions, and configuration paths printed by
brew info php.
This reviewed workflow is intentionally narrower than the archived version: identify the active CLI PHP, use Homebrew’s supported package commands, and verify the result without assuming one installer, path, shell, processor, or web server fits every Mac.