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);
print_r($ouput);

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);
print_r($output);

it will work. viola!

Like it.? Share it:
Tags: ,

Comments are closed.