shell_exec で bash スクリプトを開始できません

shell_exec で bash スクリプトを開始できません

ここ数日、私はグーグルで検索して PHP スクリプトでこの問題を解決しようとしてきましたが、PHP スクリプトで Bash スクリプトを起動する際に私が見逃している問題を誰かが理解してくれることを願っています。

これが私の PHP です:

//kickoff the yapeal script
echo "Starting yapeal.sh<br>";
echo "Current working directory: ";
echo getcwd() . "\n";
shell_exec('./yapeal.sh');
echo "<br>yapeal.sh ran, I hope.<br>";

こちらがyapeal.shです

#!/bin/bash
cd /var/www/tools/applications
php -f /var/www/lib/yapeal/yapeal.php
sleep 5s
echo "`date -u` Yapeal kicked off, working" > bashoutput.log 2>&1

ファイルの権限は次のとおりです:

-rwxrwxrwx 1 www-data www-data 4640 Jul 10 07:20 index.php
-rwxrwxrwx 1 www-data www-data 2845 Jul 10 07:33 working.php
-rwxrwxrwx 1 www-data www-data  232 Jul 10 07:17 yapeal.sh

Web ブラウザで出力として得られるものは次のとおりです。

Starting yapeal.sh
Current working directory: /var/www/tools/applications
yapeal.sh ran, I hope.

bashoutput.log ファイルには出力がありません。

php.ini を確認しましたが、disable_functions セクションに exec または shell_exec への参照はありません。

答え1

私は自分の問題を自分で解決しました。

PHP コードを次のように変更しました:

$output = shell_exec('./yapeal.sh');
echo $output;

関連情報