PHP 7 on macOS SierraApple has released the latest version of their OS X operating system to the broad public and many have already upgraded their mac devices. But as it goes with each release, Apple likes to do things a bit different making it quite challenging for PHP developers to stay current with the latest PHP version (or other versions).
This version of mac OS (11.12) comes pre-installed with PHP 5.6.24.
PHP 5.6.24 (cli) (built: Aug 8 2016 16:58:37)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
Good for Apple, but this version reaches end-of-life support by the end of this year, so it would be great if you could upgrade to PHP 7.0 or even play with the latest PHP 7.1 release candidates.
Of course you can always turn to Homebrew, XAMMP or whatever package manager you use for easy installations, but taking the compiling path is just as complicated. The failure is equal in most situations.
Configuring PHP on macOS Sierra triggers the following error:
apxs:Error: /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.12.xctoolchain/usr/local/bin/apr-1-config not found!.
configure: error: Aborting
In this version of Apple's OS the Apache Portable Runtime was not included. You need to download it and compile it yourself.
Check the checksums!
tar -xjf apr-1.5.2.tar.bz2
tar -xjf apr-util-1.5.4.tar.bz2
sudo mkdir -p /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.12.xctoolchain/usr/local/bin/
sudo ln -s /usr/local/apr/bin/apu-1-config /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.12.xctoolchain/usr/local/bin/apu-1-config
sudo ln -s /usr/local/apr/bin/apr-1-config /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.12.xctoolchain/usr/local/bin/apr-1-config
Now you can hapily compile and run the latest PHP version on the latest OS from Apple. See my previous article Compile PHP 7 on Mac OS X 10.11 "El Capitain" for instructions.