installphp.info


← Back to home page

Install PHP 7.0 on macOS 11

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

PHP 7.0 reached end of life on 03 Dec 2018 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 7.0 on macOS 11

Prerequisites

  • macOS 11 (Big Sur) installed
  • Command Line Tools for Xcode installed
  • Homebrew package manager installed

Installation

  1. Open Terminal
  2. Run the following command to update Homebrew:
    brew update
  3. Install PHP 7.0 using Homebrew:
    brew install [email protected]
  4. Add PHP 7.0 to your PATH:
    echo 'export PATH="/usr/local/opt/[email protected]/bin:$PATH"' >> ~/.zshrc
    echo 'export PATH="/usr/local/opt/[email protected]/sbin:$PATH"' >> ~/.zshrc
  5. Reload your shell configuration:
    source ~/.zshrc

Verification

  1. Check the installed PHP version:
    php -v
  2. The output should display PHP 7.0.x
  3. Verify PHP configuration:
    php -i
  4. Create a test PHP file:
    echo '<?php phpinfo();' > phpinfo.php
  5. Run the test file:
    php phpinfo.php
  6. If successful, you should see detailed PHP configuration information