I would share this, save the requirement as an event in some repository (redis, for example, or even rabbitmq), and listen to this with some demonized script (cron would be a bad junk, since it is difficult to get it to run more often than every minute). The script will update the repository record with the results, and again you can access it in your HTTP stack. You can implement the allity function via ajax or use the usleep command in php to wait for the results. If you use a while loop, be sure to break it after 1 second or something else, so the request does not work for too long.
The problem may be the user configured to execute the php binary - perhaps he is not allowed to access these binaries on your system. Usually this is www-data user. By adding the www-data user to the desired group, you can solve it without disassembling everything. Take a look at binary owners and permissions to figure this out.
source share