installphp.info


← Back to home page

Install PHP 8.0 on macOS 12

Warning! This PHP version is end-of-life!

PHP 8.0 reached end of life on 26 Nov 2023 and is no longer being updated. It's strongly recommended to upgrade to the latest version as soon as possible. You can read the official PHP migration guide here.

Installing PHP 8.0 on macOS 12

Prerequisites

  • macOS 12 (Monterey) installed
  • Command Line Tools for Xcode installed
  • Homebrew package manager installed

Installation

  1. Open Terminal
  2. Update Homebrew:
    brew update
  3. Install PHP 8.0:
    brew install [email protected]
  4. Link PHP 8.0:
    brew link [email protected]
  5. Add PHP to your PATH:
    echo 'export PATH="/usr/local/opt/[email protected]/bin:$PATH"' >> ~/.zshrc
  6. Reload your shell configuration:
    source ~/.zshrc

Verification

  1. Check PHP version:
    php -v
  2. Verify PHP configuration:
    php -i
  3. Test PHP by creating a simple script:
    echo '<?php phpinfo();' > phpinfo.php
  4. Run the script:
    php phpinfo.php