RSS
 

Howto: Enable PCNTL in Ubuntu PHP installations

30 Jul

PCNTL in PHP allows for some handy advanced “trickery” using the OS process functions inherent in Linux (*nix?).  I believe some features are available in Windows, but I know for certain that pcntl_fork() is not.

Anyway, it is not enabled by default, so if you want to take advantage of the functions on your Ubuntu LAMP server, you might spend hours searching the web for that magic aptitude command.  But, as far as I can tell, it doesn’t exist.

Luckily, I stumbled across this article on the Ubuntu forums, so I’m dedicating a post here with the hopes that other will find it more easily.

Please note that you’ll probably need build-essentials and a few other source compilation basics, but as long as you have that, the following code will get you what you want.

First, in your home directory:

mkdir php
cd php
apt-get source php5
cd php5-(WHATEVER_RELEASE)/ext/pcntl
phpize
./configure
make

Then:

cp modules/pcntl.so /usr/lib/php5/WHEVER_YOUR_SO_FILES_ARE/
echo "extension=pcntl.so" > /etc/php5/conf.d/pcntl.ini

FYI: “make install” does not appear to put the files in the correct place.

Btw, please direct any thanks/praise to skout23 on the Ubuntu forums.

 
 

Tags: , , , , , , ,

Leave a Reply

 

 
  1. Dustin

    November 7, 2010 at 6:55 am

    Thanks!

     
  2. Nasos

    November 25, 2010 at 12:19 pm

    You’re the man!

    I was looking everywhere in the web to find a solution without recompiling the entire php.

    Thank you very very much!

     
  3. Liam

    January 27, 2011 at 10:28 am

    Good stuff, but I can’t find phpize?

    I ended up doing this:
    http://www.uluga.ubuntuforums.org/showthread.php?t=214739

    but it seems to be doing a lot more than necessary :-(

     
    • Jeremy

      January 31, 2011 at 1:56 pm

      It’s in the php5-dev package. (sudo apt-get install php5-dev)

      user@laptop:~$ phpize
      No command 'phpize' found, did you mean:
      Command 'phpize5' from package 'php5-dev' (main)

      Hope this helps!

       
  4. Adding Pcntl Support to a Shared Host | Stuporglue.org

    March 12, 2011 at 9:27 pm

    [...] thanks to http://www.crimulus.com/ for the headstart on [...]

     
  5. Jonathan

    November 14, 2011 at 11:58 pm

    Awesome! Just what I needed. Thank you.