W3docs

Update PHP to 7.4 macOS Catalina with brew

To update PHP to version 7.4 on macOS Catalina using Homebrew, you can use the following steps:

To update PHP to version 7.4 on macOS Catalina using Homebrew, you can use the following steps:

  1. Run brew update to ensure your Homebrew installation is up-to-date.
  2. Run brew unlink php to safely deactivate any previous PHP versions that may be installed.
  3. Run brew install [email protected] to install the latest version of PHP 7.4. (Note: PHP 7.4 reached end-of-life in November 2022 and is no longer in Homebrew's core repository. You may need to tap the php repository or use archived formulas to install it.)
  4. Verify that PHP 7.4 is now the active version by running php -v.
  5. If you are using a web server like Apache or Nginx, you will need to configure it to use the new PHP version. Note that Apache is disabled by default on macOS Catalina. For Apache, you will need to edit the httpd.conf file and update the PHP module path.
  6. Restart your web server to ensure it's using the new version of PHP.
  7. To update your PHP extensions, you can run pecl channel-update pecl.php.net and pecl upgrade-all.

Please note that these steps may not be suitable for all use cases and you should backup your data before proceeding with any updates.