我在Heroku上有一些PHP应用程序。当我启用PHP时,我也运行此命令,I've found somewhere at 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
答案 0 :(得分:0)
工作正常
$cmd = "/app/php/bin/php -v " ...
答案 1 :(得分:0)
使用 / app / php / bin / php 而非 ./ app / php / bin / php
两者都不一样,因为后者会搜索文件根目录中的/ app文件夹,即/ app / www /,因此在/ app / www /
中找不到app文件夹