• Skip to main content
  • Skip to primary sidebar

Code Inherit

Simple Programming Code Examples

How to install PHP 8.1 alongside PHP 7.4 using HomeBrew in MacOs?

7th September 2024 by Site Admin Leave a Comment

To install PHP 8 alongside PHP 7.4 and have it in a sibling directory (e.g., /opt/homebrew/etc/php/8.0 or /opt/homebrew/etc/php/8.1), follow these steps:

1. Add the shivammathur/php Tap:

First, you need to add the shivammathur/php tap to access older PHP versions, including PHP 8.x.

brew tap shivammathur/php

2. Install PHP 8.1 (or PHP 8.0):

To install PHP 8.1, use the following command:

brew install shivammathur/php/php@8.1

This will install PHP 8.1 and place its configuration and binaries in a sibling directory to PHP 7.4, such as /opt/homebrew/etc/php/8.1.

If you prefer PHP 8.0, run:

brew install shivammathur/php/php@8.0

3. Check the Installation Location:

You can check where PHP 8 is installed with the following:

brew info php@8.1

This will show you the location of PHP 8.1, which should be something like /opt/homebrew/etc/php/8.1 if you are using Homebrew installed in /opt/homebrew.

4. Switch Between Versions:

You can now use the brew unlink and brew link commands to switch between PHP 7.4 and PHP 8.

  • To switch to PHP 8.1:
  • brew unlink php@7.4
  • brew link php@8.1 --force --overwrite
  • To switch back to PHP 7.4:
  • brew unlink php@8.1
  • brew link php@7.4 --force --overwrite

Now, PHP 7.4 and PHP 8.x will reside in sibling directories, and you can easily switch between them.

Filed Under: Uncategorised

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar

Recent Posts

  • Bijoy Converter
  • How to amend previous commit with current changes in git and github?
  • How to install PHP 8.1 alongside PHP 7.4 using HomeBrew in MacOs?
  • Create a shell script to switch 7.4 to 8.1 and vice versa
  • How to reflect PHP8.1 to Apache in MacOS?

Recent Comments

    Archives

    • October 2025
    • September 2024
    • January 2024
    • July 2023
    • October 2021
    • September 2021
    • February 2021
    • January 2021
    • October 2020
    • September 2020
    • August 2020
    • May 2020
    • March 2020
    • February 2020
    • January 2020
    • November 2019
    • May 2019

    Categories

    • Couchbase
    • Cron Job
    • dhis2
    • Linux, MySQL
    • MySQL
    • Oracle
    • Oracle Client
    • PHP
    • SSL
    • Subdomain
    • Uncategorised
    • Wordpress
    • WP
    • Zip

    Meta

    • Log in
    • Entries feed
    • Comments feed
    • WordPress.org

    Copyright © 2025 · Genesis Sample on Genesis Framework · WordPress · Log in