Adding Pcntl Support to a Shared Host

If you are using a shared hosting solution you may not have pcntl support compiled into the PHP you are using. It’s actually not terribly difficult to add it yourself if your host allows it, and if you have build tools available to you on your host. Here’s how I did it when we needed pcntl support on our Media Temple grid server (gs).

The following steps are all done on the server over SSH. If you don’t have SSH access you probably need a new hosting service.

Pcntl tools are only really useful if you are running command line scripts, such as writing a daemon in PHP.

The exact steps will be different for different hosting services of course, but this is what worked for me

Many thanks to for the headstart on this.

The first step is to find your PHP version

php --version

Find and Download That Version’s Source Code

Check here:

wget (download it)
tar xjf php-5.2.14.tar.bz2 (extract it)

Enter The Pcntl Source Directory

cd php-5.2.14/ext/pcntl


Prepare phpize to Work With Your Environment

(if phpize is already installed this step may not be needed)

chmod +x phpize

Find the Build Directory for Your Version of PHP

cd /
find . -name "build" 2>/dev/null
./usr/local/php-5.2.14/lib/php/build <========
cd -

Edit phpize so that phpdir and includedir Point at That Location

1 #!/bin/sh
3 # Variable declaration
4 prefix='/usr'
5 exec_prefix="`eval echo ${prefix}`"
6 phpdir="$prefix/local/php-5.2.14/lib/php/build"
7 includedir="$prefix/local/php-5.2.14/lib/php"
8 aclocaldir="$prefix/share/aclocal"
9 builddir="`pwd`"
10 SED="/bin/sed"

Run phpize


Configure and Make

Find php-config

(it’s probably in the bin directory of the php-5.2.14 directory you found earlier)

cd /
find . -name php-config 2>/dev/null
./usr/local/php-5.2.14/bin/php-config <=========
cd -

Run Configure

./configure --with-php-config=/usr/local/php-5.2.14/bin/php-config

Run Make


Install and Use It

Create a happy place for it

mkdir ~/php-modules
cp modules/ ~/php-modules

Create a php.ini File

Make a php.ini in your home directory file with at least the following lines.


Run your script!

php -c /path/to/your/home/php.ini /path/to/your/php/script.php



This entry was posted in Something Interesting. Bookmark the permalink.

2 Responses to Adding Pcntl Support to a Shared Host

  1. Pingback: StatusNet : queuedaemon, pcntl et hébergement mutualisé

  2. Pingback: StatusNet : queuedaemon, pcntl et hébergement mutualisé | PostBlue

Leave a Reply

Your email address will not be published. Required fields are marked *