I am working on a project that has a webserver(thats currently running from my laptop) and a RaspberryPi. I made a simple website with HTML, PHP and Javascript and i have a working python programm on my RaspberryPi. What i want to do is, to start the python programm using php currently i am using this command.
exec('sudo python /var/www/LED-Ring/python/examples/LED-Ring.py');
When i run the command directly in the terminal
sudo python /var/www/LED-Ring/python/examples/LED-Ring.py
it works just fine.
I have already added the following
www-data ALL=NOPASSWD: ALL
into sudo visudo (i know that this is a security risk but i dont care right now i just want to get it to work)
what do i need on the Pi even though the webserver is running on the laptop?
the only thing the raspi needs to be able to do is to open the browser and go on the website.(which it already does) and then whenever the webserver send the command, the python script should start
the problem is probably related to permissions because i can run the python script with
"sudo python /var/www/LED-Ring/python/examples/LED-Ring.py"
but i cant run it with
"sudo -u www-data python /var/www/LED-Ring/python/examples/LED-Ring.py"
when i use that command i get
Failed to create mailbox device : Operation not permitted
File "/var/www/LED-Ring/python/examples/LED-Ring.py", line 52, in module strip.begin
File "build/bdist.linux-armv7l/egg/neopixel.py", line 106 in begin
RuntimeError: ws2811:init failed with code -9 (failed to create mailbox device)