How to install PHP on MAC

Run brew update command

brew update 

If the Homebrew is not installed then you can install it from

Run brew install php@7.4 command to install PHP

brew install php@7.4

Run the following command to restart the PHP service

brew services restart php@7.4


Successfully started `php@7.4` (label: homebrew.mxcl.php@7.4)

Run the following command to create a symlink for php:

export PATH=”/opt/homebrew/opt/php@7.4/bin:$PATH

More details on creating a symlink for the terminal for php:

You can type run the following command to verify that the PHP is insatlled succesfully

php -v


PHP 7.4.29 (cli) (built: Apr 14 2022 11:36:10) ( NTS )