installphp.info


← Back to home page

Install PHP 7.1 on macOS 12

This version of PHP is actively supported.

Good news! PHP 7.1 is being actively supported through 10 Nov 2024. After that point, it's advisable to upgrade to the latest version, since the PHP team will only offer security-related support until 10 Nov 2024, at which point PHP 7.1 will be considered "end-of-life".

Installing PHP 7.1 on macOS 12

Prerequisites

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

Installation

  1. Open Terminal
  2. Run the following command to tap the necessary Homebrew repository:
    brew tap shivammathur/php
  3. Install PHP 7.1 using Homebrew:
    brew install shivammathur/php/[email protected]
  4. Link the installed PHP version:
    brew link [email protected] --force

Verification

  1. Open a new Terminal window or restart your current session
  2. Verify the PHP version by running:
    php -v
  3. The output should show PHP 7.1.x
  4. To check the location of the installed PHP, run:
    which php
  5. The output should point to the Homebrew installation directory