On Windows
You can't install the pcntl
extension on Windows. According to the PHP documentation:
Note: This extension is not available on Windows platforms.
Try using Vagrant or a plain virtual machine with a Linux distributions like Ubuntu, Debian or Mint.
On Unix
First, type in your command line in your home directory:
mkdir php
cd php
apt-get source php5
cd php5-(WHATEVER_RELEASE)/ext/pcntl
phpize
./configure
make
Then do this:
cp modules/pcntl.so /usr/lib/php5/WHEVER_YOUR_SO_FILES_ARE/
echo "extension=pcntl.so" > /etc/php5/conf.d/pcntl.ini
Finished!
On Mac
Taken from an answer to How can I enable process control extension (PCNTL) in PHP MAMP?!
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 OS X v10.6 (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 OS X. 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 Unsupported Historical Releases. Untar and cd to php-[version]/ext/pcntl, e.g.:
wget http://museum.php.net/php5/php-5.3.6.tar.gz
tar xvf php-5.3.6.tar.gz
cd php-5.3.6/ext/pcntl
You then need to run phpize
in the pcntl directory, which is a binary file that comes with MAMP:
/Applications/MAMP/bin/php/php5.3.6/bin/phpize
This creates a bunch of files that are needed for preparing an extension for compiling.
We now need to add some flags to tell it to compile the library with dual 32-bit and 64-bit architecture, as the MAMP PHP has been built this way. If you don't do this, the compiled shared objects won't work.
MACOSX_DEPLOYMENT_TARGET=10.6
CFLAGS="-arch i386 -arch x86_64 -g -Os -pipe -no-cpp-precomp"
CCFLAGS="-arch i386 -arch x86_64 -g -Os -pipe"
CXXFLAGS="-arch i386 -arch x86_64 -g -Os -pipe"
LDFLAGS="-arch i386 -arch x86_64 -bind_at_load"
export CFLAGS CXXFLAGS LDFLAGS CCFLAGS MACOSX_DEPLOYMENT_TARGET
We can then run ./configure
and make
to build our shared object:
./configure
make
This puts a file called pcntl.so
in the modules directory. Copy this file to your MAMP's PHP extensions directory:
cp modules/pcntl.so /Applications/MAMP/bin/php/php5.3.6/lib/php/extensions/no-debug-non-zts-20090626/
Finally, edit the PHP INI file to include the extension:
echo "extension=pcntl.so" >> /Applications/MAMP/bin/php/php5.3.6/conf/php.ini
PCNTL should now be enabled. To check to see whether it has been added, just run:
/Applications/MAMP/bin/php/php5.3.6/bin/php --ri pcntl
pcntl
pcntl support => enabled
If you see that, it's worked!
Helpful resources
For Windows:
For Unix operating systems:
For Mac:
Other information: