Reputation: 3640
On my Raspberry Pi Model B-Rev2 running Raspbian 3.10.25 I following the instructions on https://github.com/ronanguilloux/php-gpio to control the pins. But I simple cannot get it to work. According to instructions this should be the command in triggerMyScript.php
:
exec('sudo -t /usr/bin/php ./myGpioScript');
But depending on content in myGpioScript
I get errors in Apache log error.log
saying stuff like command not found
and No such file or directory
.
I have also made additions to /etc/sudoers as instructed.
It works perfectly fine if I run php triggerMyScript.php
from the command line.
Upvotes: 2
Views: 1215
Reputation: 3640
After spending several hours I found the solution. I needed to do the following things beside what the instructions on php-gpio says:
myGpioScript
the first line had to be #!/usr/bin/php
instead of #!/usr/bin/env php
php
after -t
, like this: exec('sudo -t php /usr/bin/php ./myGpioScript');
(which makes sense when you think about it, but instructions doesn't say it like that)www-data ALL=NOPASSWD: /usr/bin/php
- so that www-data can also run php without limitations. Specifying permission for the actual script files was actually not necessary!File permissions on any of the files are not relevant either, so just leave them low.
Upvotes: 2