Enable PHP PCNTL extension with MAMP
PHP as part of MAMP (Mac, Apache, MySQL and PHP) does not come with the process control extension enabled. There is a way of compiling PCNTL as an extension and linking it in to an existing PHP build, but it's a bit in-depth.
I'm doing the following on Mac OSX Snow Leopard (64bit), with MAMP and PHP version 5.3.6. Remember to change PHP version numbers in the following lines if yours is different!
Please note that make
is required, which isn't installed by default on Mac OSX. You need to install this via Mac developer tools, http://developer.apple.com/unix/
First, download a tar of the PHP source code that matches the version you are using in MAMP (e.g. mine is 5.3.6), which you can do at http://www.php.net/releases/. Untar and CD to php-[version]/ext/pcntl, e.g.:
You then need to run phpize
in the pcntl directory, which is a binary file that comes with MAMP:
This creates a bunch of files that are needed for preparing a extension for compiling.
We now need to add some flags to tell it to compile the library with dual 32bit and 64bit architecture, as the MAMP PHP has been built this way. If you don't do this, the compiled shared objects won't work.
We can then run ./configure
and make
to build our shared object:
This puts a file called pcntl.so
in the modules directory. Copy this file to your MAMP's PHP extensions directory:
Finally, edit the PHP INI file to include the extension:
PCNTL should now be enabled. To check to see whether it has been added, just run:
If you see that, it's worked! If anything has gone wrong you can just remove the pcntl.so
file from the MAMP PHP extensions directory and remove the INI setting, and try again.