M
M
Mraleks102019-12-13 13:56:27
Raspberry Pi
Mraleks10, 2019-12-13 13:56:27

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

2 answer(s)
A
Alexander, 2019-12-13
@NeiroNx

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.

N
Nikita Kolesnikov, 2019-12-13
@NikitOS_MV

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 question

Ask a Question

731 491 924 answers to any question