On a somewhat related note: Today I was attempting to use some CLI tools I've written on a web page, calling exec(), or shell_exec(), or using backticks, or whatever. Some of them worked, and some didn't.
After a good deal of head scratching, the problem became apparent. The failing tools were calling PHP or Python via env, thus:
#!/usr/bin/env python2
# Python code here
Since the Apache server doesn't have many environment vars to speak of, PHP couldn't find python2 (or even the CLI version of itself) if it was called with env. The quickest fix was to modify the tools to use /usr/local/bin/python2 or /usr/local/bin/php directly:
#!/usr/local/bin/php -q
<?php
// do PHP stuff