0

I'm playing with Raspberry Pi and anm Arduino shield in order to run a script via Apache/PHP. This script simple blink a LED. I have already tested the script via shell and it works fine, with the command

/root/arduPi/blink_test

I'm able to see my LED blinking. So I made the same thing via Apache PHP with this short PHP script

<?php
    if(isset($_GET['cmd'])){
        echo '/root/arduPi/'.$_GET['cmd'];
        exec('/root/arduPi/'.$_GET['cmd']);
    }
?>

but nothing happen and no error has been displayed.

I tested the PHP code with

<?php
    phpinfo();
?>

and it's fine. How can I fix this problem?

4

1 回答 1

0

不久前我遇到了同样的问题,因为 Apache 无权访问 Pi 上的某些设备。我通过摆脱以 root 身份访问这些设备的需要来解决此问题。是我关于这个问题的帖子,修复方法是将 sudo 设置为无密码。 就是我用来完成将 sudo 设置为无密码的方法。然后,您应该能够按如下方式执行脚本exec('sudo /root/arduPi/'.$_GET['cmd']);

于 2013-04-08T19:06:50.103 回答