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 http://www.crimulus.com/ 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: http://php.net/releases/index.php
wget http://museum.php.net/php5/php-5.2.14.tar.bz2 (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)
wget stuporglue.org/downloads/phpize chmod +x phpize
Find the Build Directory for Your Version of PHP
cd / find . -name "build" 2>/dev/null ./usr/share/apache2/build ./usr/local/php-5.3.2/lib/php/build ./usr/local/php-5.2.14/lib/php/build <======== ./usr/local/php-4.4.9/lib/php/build cd -
Edit phpize so that phpdir and includedir Point at That Location
1 #!/bin/sh
2
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
./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.3.2/bin/php-config ./usr/local/php-5.2.14/bin/php-config <========= ./usr/local/php-4.4.9/bin/php-config cd -
Run Configure
./configure --with-php-config=/usr/local/php-5.2.14/bin/php-config
Run Make
make
Install and Use It
Create a happy place for it
mkdir ~/php-modules cp modules/pcntl.so ~/php-modules
Create a php.ini File
Make a php.ini in your home directory file with at least the following lines.
extension_dir=/path/to/your/home/php-modules extension=pcntl.so
Run your script!
php -c /path/to/your/home/php.ini /path/to/your/php/script.php
Enjoy!
