cpanel php exec – memory or cannot fork error

If you are using php, and try to run command line scripts containing php command, you will get a loop that fails with a warning “cannot fork” or memory error.

This is because you are most likely using suphp in cpanel. While suphp is popular, it fails misery when trying to execute php command line. You might have something like this:

exec(‘composer update’,$output);

to see the errors:

exec(‘composer update 2>&1’, $output);

You could have use the php system() function instead. The result is the same. You will see lots of loops and php die with cannot fork error.

So what is the error? Google doesn’t reveal anything. The reason is that php by default is using /usr/bin/php which suphp works on top of. You need to use a php free from suphp and use the full path. try this

exec(‘/usr/local/bin/php /usr/local/bin/composer update 2>&1’, $ouput);

it will work. viola!

Author: bpeh

Bernard Peh is a great passioner of web technologies and one of the co-founder of Website Design and Reviews. He works with experienced web designers and developers everyday, developing and designing commercial websites. He specialises mainly in SEO and PHP programming.