On the command line, run the following commands:


# Please refer to https://guide.macports.org/chunked/installing.macports.html for installing MacPorts.

# Install PHP 

sudo port install php


# Switch Active PHP  version
sudo port select php php