Install PHP on MacOS
Step 1. Install Homebrew
Install Homebrew, if it is not already installed.
- This will take a couple of minutes.
- Follow any steps that it recommends afterward.
Step 2. Install PHP
Use Homebrew to install PHP.
brew install php
- Note: If it gets stuck, just hit Enter to flush the output.
Step 3. Check It
Check the PHP version.
$ php -v
You will see something like this:
PHP 8.3.9 (cli) (built: Jul 2 2024 14:10:14) (NTS) Copyright (c) The PHP Group Zend Engine v4.3.9, Copyright (c) Zend Technologies with Zend OPcache v8.3.9, Copyright (c), by Zend Technologies
Great!