If you wish to install PHP 7.2 and disable Apache you can follow the steps below.


PHP 7.2


As shown below Mac OS Sierra comes with PHP 5.6 below by default.


$ php -v
PHP 5.6.30 (cli) (built: Feb 7 2017 16:18:37)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies

$ which -a php
/usr/bin/php

Upgrade PHP to version 7.2.


$ curl -s http://php-osx.liip.ch/install.sh | bash -s 7.2
Detected macOS Sierra 10.12. All ok.
...
Installing package 7.2-10.10-frontenddev into root /
...
Restarting Apache
Syntax OK
Finished.

Update environment variable.


$ export PATH=/usr/local/php5/bin:$PATH
--- Verify.
$ php -v
PHP 7.2.2 (cli) (built: Feb 1 2018 13:23:34) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.2.2, Copyright (c) 1999-2018, by Zend Technologies
with Xdebug v2.6.0, Copyright (c) 2002-2018, by Derick Rethans

$ which -a php
/usr/local/php5/bin/php
/usr/bin/php

Make change permanent.


$ echo "export PATH=/usr/local/php5/bin:$PATH" >> ~/.bash_profile

Apache


Stop it.


$ sudo apachectl stop

Turn it off.


$ sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist

Note: You might need to restart the device.