# macOS

> Section in “Introduction › Getting PHP 7” of the book [PHP 7 Explained](https://php7explained.com/) by Sebastian Bergmann and Stefan Priebsch, published by thePHP.cc. The book covers PHP 7.0 to 7.4 and was last updated in November 2020. HTML version: <https://php7explained.com/introduction/getting-php-7/macos/>

The two most common ways to install PHP on macOS are using [Homebrew](https://brew.sh/) and [MacPorts](https://www.macports.org/). The instructions given below assume that you have Homebrew or MacPorts already set up.

## Homebrew

    $ brew update

    $ brew install php74

## MacPorts

    $ sudo port selfupdate

    $ sudo port install php74

---

Previous: [Ubuntu](https://php7explained.com/introduction/getting-php-7/ubuntu/index.html.md) | Next: [Microsoft Windows](https://php7explained.com/introduction/getting-php-7/microsoft-windows/index.html.md)
