Php WooCommerce在订单完成时触发函数,但其中调用的Python脚本不会执行

Php WooCommerce在订单完成时触发函数,但其中调用的Python脚本不会执行,php,python,wordpress,woocommerce,Php,Python,Wordpress,Woocommerce,我是Wordpress/Woocommerce的新手,正在尝试在订单完成后启动python脚本。我创建了以下插件: <?php /** * Plugin Name: Run Python Script on Order Completion * Plugin URI: http://www.mindspan.net * Description: Fires a Python script which queries the database

我是Wordpress/Woocommerce的新手,正在尝试在订单完成后启动python脚本。我创建了以下插件:

<?php

    /**
     * Plugin Name: Run Python Script on Order Completion
     * Plugin URI: http://www.mindspan.net
     * Description: Fires a Python script which queries the database
     * Version: 1.0
     * Author: Ray Richards
     * Author URI: http://www.mindspan.net
     */

    ini_set('display_errors', 1);
    ini_set('display_startup_errors', 1);
    error_reporting(E_ALL);

    function  logIt( $order_id ) {
        error_log( "Order complete for order $order_id", 0 );
        $command = escapeshellcmd('/var/www/html/wp-content/plugins/mindspan/getValues.py');
        shell_exec($command);
    }
    add_action( 'woocommerce_order_status_completed', 'logIt', 10, 1 );

    ?>
文件夹和文件归www数据用户所有(位于谷歌云平台上的Debian stretch上),当我向该用户发出命令并从命令行执行该功能时(注释添加操作部分):

执行Python脚本并创建包含结果的文件

我还尝试了system()和passthru(),并在调用Python脚本的两行之后放置了另一个错误日志,它也在日志中输出该消息。当我创建另一个包含以下内容的test.php文件时:

<?php
//$command = escapeshellcmd('/var/www/html/wp-content/plugins/mindspan/getValues.py');
//shell_exec($command);

passthru('/usr/bin/python /var/www/html/wp-content/plugins/mindspan/getValues.py 1 2>&1');
?>

并从命令行运行它,注释命令和未注释命令都能按预期工作。我甚至(暂时)将目录权限更改为777。。。没有骰子


因此,我想了解当从PHP调用Python脚本时,是什么阻止了它的运行。如有任何建议,将不胜感激

您是否检查了php.ini中的“disable_functions”指令?@magenta感谢您的回复。我的禁用函数如下:`disable_functions=pcntl_报警、pcntl_分叉、pcntl_等待、pcntl_退出、pcntl_wifstopped、pcntl_wifsigned、pcntl_wifccontinued、pcntl_退出状态、pcntl_wtermsig、pcntl_waitsig、pcntl_信号、pcntl_信号发送、pcntl_获取最后一次错误、pcntl_strerror、pcntl_strerror、pcntl_-sigu-procfg掩码、pcntl-sigu-waitu-sigu、pcntu-waitu-wait、pcntu-sigu,pcntl_exec,pcntl_getpriority,pcntl_setpriority,`这些都有问题吗?我认为这不是问题,因为我可以直接从PHP运行脚本。我还将www data ALL=(ALL)NOPASSWD:/etc/bin/python添加到我的sudoers文件中,并尝试在脚本中使用nohup。。。所有这些都没有用。它也确实在尝试运行python脚本,因为当我在脚本中输入语法错误时,它会显示在/var/log/apache2/error.log中,所以问题可能是将输出写入文件,但我看不到任何权限问题。
sudo su www-data -s /bin/sh
php -r "require 'myFile.php'; logIt(8679);"
<?php
//$command = escapeshellcmd('/var/www/html/wp-content/plugins/mindspan/getValues.py');
//shell_exec($command);

passthru('/usr/bin/python /var/www/html/wp-content/plugins/mindspan/getValues.py 1 2>&1');
?>