Upgrading PHP 5.6 on macOS Sierra running Server 5.2

This has been a long struggle, but here it is - the guide for upgrading PHP 5.6 on macOS Sierra running Server 5.2. What started it all was that I wanted to switch from Google Analytics to Piwik, a self hosted web analytics software. The challenge was that the PHP configuration