Using the bundled PHP prior to macOS MontereyPHP is bundled with macOS since macOS X (10.0.0) prior to macOS Monterey (12.0.0). Enabling PHP with the default web server requires uncommenting a few lines in the Apache configuration file httpd.conf whereas the CGI and/or CLI are enabled by default (easily accessible via the Terminal program). Enabling PHP using the instructions below is meant for quickly setting up a local development environment. It's highly recommended to always upgrade PHP to the newest version. Like most live software, newer versions are created to fix bugs and add features and PHP being is no different. See the appropriate macOS installation documentation for further details. The following instructions are geared towards a beginner with details provided for getting a default setup to work. All users are encouraged to compile, or install a new packaged version. The standard installation type is using mod_php, and enabling the bundled mod_php on macOS for the Apache web server (the default web server, that is accessible via System Preferences) involves the following steps:
The CLI (or CGI in older versions) is
appropriately named php and likely exists as
/usr/bin/php. Open up the terminal, read the
command line section of the PHP
manual, and execute |