NYCPHP Meetup

NYPHP.org

[nycphp-talk] What does PHP use to find programs that are exec'ed?

Jayesh Sheth jay_nyphp at fastmail.fm
Wed Jun 22 16:23:22 EDT 2005


Hello all,

I was wondering what the PHP 4 module of Apache uses to find programs
when using the exec() function. 
I am trying to use a script invoked through the Apache PHP 4 module to
exec() the CLI version of PHP.

For example http://localhost/test.php has:
<?php
$output = '';
$exec = '';
exec('php --help', $output, $exec);
print_r($output);
?>

I compiled PHP 4.3.x as an Apache module, but also seems to have
installed the CLI version in:
/usr/local/bin/php

The above exec call from does work. 

However, I compiled PHP 5 with: '--disable-cgi' '--enable-cli' and
copied the PHP 5 binary to /usr/bin . When I change
http://localhost/test.php to be:

<?php
$output = '';
$exec = '';
exec('/usr/bin/php5_0 --help', $output, $exec);
print_r($output);
?>

no it does not work (no output is produced).

The phpinfo() function for the PHP 4 Apache module (through which exec()
requests are being passed) has the following info for Apache's
environment variables:
PATH    /bin:/usr/bin:/usr/local/bin

When as root I do:
echo $PATH 

I get:
/sbin:/bin:/usr/sbin:/usr/bin:/usr/bin/X11:/usr/local/sbin:/usr/local/bin

Apache's user and group are both www-data.

So my question is:
what do I need to do to let the PHP 4 Apache module find a program so it
can exec() it?

Thanks in advance.

Best regards,

- Jay



More information about the talk mailing list