I used this tutorial (sorry, it's German) to switch my 433MHz sockets: https://tutorials-raspberrypi.de/raspberry-pi-funksteckdosen-433-mhz-steuern/
I compiled a file that switches the sockets on and off by RC code. If I run it directly on the Pi Shell it works fine:
sudo /var/www/html/bin/RPiControl -3313
but if I run it via exec()
on my PHP script, it does not:
exec('sudo /var/www/html/bin/RPiControl -3313', $output, $return);
Here's what I tried so far:
- There is no return/output value
- I'm using lighttpd as webserver on Raspi 3 with default Raspian
- The script is located at /var/www/html
- The binary is located at /var/www/html/bin (also tried the home directory)
- The webserver/php seems to run under the default user "pi" (I'm wondering, on my other linux machines it used to be www-data user)
- I tried to gave sudo permissions to the "pi" user (tried www-data as well)
- I made the "Pi" User owner of the PHP script(s) and the binary
- I chmodded the PHP scripts with 777
- I already tried this: sudo in php exec()
I guess it's a permission issue to use "sudo" with PHP execute. If I try sudo la la
it's not working as well.
How can I allow the binary to be executed without sudo
, or allow PHP to use sudo
?
Thanks in advance.