我在 Heroku 上获得了一些 PHP 应用程序。当我启用 PHP 时,我也运行了这个命令,我在 Stackoverflow 的某个地方找到了这个命令:
heroku config:add LD_LIBRARY_PATH=/app/php/ext:/app/apache/lib
Setting config vars and restarting zfq... done, v7
LD_LIBRARY_PATH: /app/php/ext:/app/apache/lib
命令行中的此命令工作正常:
heroku run ./php/bin/php -v
Running `./php/bin/php -v` attached to terminal... up, run.3208
PHP 5.3.10 (cli) (built: Mar 26 2012 08:15:52)
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies
但是这段代码:
$nickname = $_POST['nickname'];
$filename = "1.txt";
$cmd = './php/bin/php -v > "' . $filename . '" 2>&1 &';
exec($cmd, $output);
$contents = file_get_contents($filename);
unlink($filename);
exit_ajax($contents);
返回sh: ./php/bin/php: not found
如果我将./php/bin/php更改为~/php/bin/php - 它会返回false
到./php - 返回sh: ./php: not found