Answer the question
In order to leave comments, you need to log in
Light up the raspberry LED through the web interface using php, or any other way?
It is necessary to light the LED using php through the web interface. In PHP, I wrote exec("sudo /var/www/html/led/***.py") to execute a Python script, but in the end the LED does not light up. PHP runs in FastCGI.
Answer the question
In order to leave comments, you need to log in
Most likely the rights are not enough. PHP runs the script with the rights of a web user who does not have the rights to pull the legs. You need to run from root - most likely you need a service that works from root and accepts commands (via a socket) and pulls the necessary outputs. It can receive commands from any application that can write to the socket.
The PHP script is being run as the www-data user, which does not have sudo permissions.
Alternatively, add to /etc/sudoers:
This gives the user www-data permission to use all commands via sudo without a password.
You can only allow the use of the python command :www-data ALL=/usr/bin/python NOPASSWD:ALL
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question