Compile PHP pcntl module on OS X Lion

PHP logo

I had some trouble compiling pcntl PHP module on OS X Lion so I thought I’d share this solution. In fact, you can use these steps to compile any other PHP module.

First download the latest php source from PHP.NET
cd into your php src directory, then:

cd ext/pcntl
phpize
./configure --enable-pcntl

When I ran the last step (configure), I got the following error:

‘PHP_FE_END’ undeclared here (not in a function)

To get around the problem, you need to specify your system architecture before configuring your extension:

CFLAGS='-arch x86_64' CXXFLAGS='-arch x86_64' LDFLAGS='-arch x86_64' ./configure --enable-pcntl

Copy compiled modules into PHP extensions:

cp modules/pcntl.so /usr/lib/php/extensions/

Enable the extension:

echo "extension=pcntl.so" >> /etc/php.ini

Marko