Note: This technique also works for other versions, just change the version number. For example, if you want to to install PHP5.6 or PHP7.3. Just change the version number wherever it appears, such as php56-apache2handler or php73-mysql.
Another tut that I found helpful, https://trac.macports.org/wiki/howto/MAMP