Recommend this page to a friend! |
PHP Led Raspberry PI | > | PHP Led Raspberry PI package blog | > | How to Use a PHP Rasp... | > | All threads | > | permissions | > | (Un) Subscribe thread alerts |
|
Joan Barns - 2021-10-13 18:41:04
I tried this and it is working except I have to refresh the page one time to get it to work other wise I get permission errors.
I have run sudo usermod -a -G gpio www-data sudo systemctl restart apache2 The initial run of led.php gives this in the apache2 error log. Any ideas? [Wed Oct 13 10:52:19.716850 2021] [mpm_prefork:notice] [pid 597] AH00169: caught SIGTERM, shutting down [Wed Oct 13 10:52:29.252244 2021] [mpm_prefork:notice] [pid 622] AH00163: Apache/2.4.38 (Raspbian) configured -- resuming normal operations [Wed Oct 13 10:52:29.261302 2021] [core:notice] [pid 622] AH00094: Command line: '/usr/sbin/apache2' [Wed Oct 13 10:53:02.161185 2021] [php7:warn] [pid 650] [client 192.168.0.235:65158] PHP Warning: fopen(/sys/class/gpio/gpio23/direction): failed to open stream: Permission denied in /var/www/html/picGPIO.class.php on line 52 [Wed Oct 13 10:53:02.161466 2021] [php7:warn] [pid 650] [client 192.168.0.235:65158] PHP Warning: fwrite() expects parameter 1 to be resource, bool given in /var/www/html/picGPIO.class.php on line 53 [Wed Oct 13 10:53:02.161524 2021] [php7:warn] [pid 650] [client 192.168.0.235:65158] PHP Warning: fclose() expects parameter 1 to be resource, bool given in /var/www/html/picGPIO.class.php on line 54 [Wed Oct 13 10:53:02.161730 2021] [php7:warn] [pid 650] [client 192.168.0.235:65158] PHP Warning: fopen(/sys/class/gpio/gpio23/value): failed to open stream: Permission denied in /var/www/html/picGPIO.class.php on line 15 [Wed Oct 13 10:53:02.161918 2021] [php7:warn] [pid 650] [client 192.168.0.235:65158] PHP Warning: fwrite() expects parameter 1 to be resource, bool given in /var/www/html/picGPIO.class.php on line 59 [Wed Oct 13 10:53:03.162157 2021] [php7:warn] [pid 650] [client 192.168.0.235:65158] PHP Warning: fwrite() expects parameter 1 to be resource, bool given in /var/www/html/picGPIO.class.php on line 59 [Wed Oct 13 10:53:04.162497 2021] [php7:warn] [pid 650] [client 192.168.0.235:65158] PHP Warning: fwrite() expects parameter 1 to be resource, bool given in /var/www/html/picGPIO.class.php on line 59 [Wed Oct 13 10:53:05.162860 2021] [php7:warn] [pid 650] [client 192.168.0.235:65158] PHP Warning: fwrite() expects parameter 1 to be resource, bool given in /var/www/html/picGPIO.class.php on line 59 [Wed Oct 13 10:53:06.163197 2021] [php7:warn] [pid 650] [client 192.168.0.235:65158] PHP Warning: fwrite() expects parameter 1 to be resource, bool given in /var/www/html/picGPIO.class.php on line 59 [Wed Oct 13 10:53:21.211355 2021] [php7:warn] [pid 650] [client 192.168.0.235:65158] PHP Warning: fwrite() expects parameter 1 to be resource, bool given in /var/www/html/picGPIO.class.php on line 59 [Wed Oct 13 10:53:22.211652 2021] [php7:warn] [pid 650] [client 192.168.0.235:65158] PHP Warning: fwrite() expects parameter 1 to be resource, bool given in /var/www/html/picGPIO.class.php on line 59 [Wed Oct 13 10:53:23.211958 2021] [php7:warn] [pid 650] [client 192.168.0.235:65158] PHP Warning: fwrite() expects parameter 1 to be resource, bool given in /var/www/html/picGPIO.class.php on line 59 [Wed Oct 13 10:53:24.212318 2021] [php7:warn] [pid 650] [client 192.168.0.235:65158] PHP Warning: fwrite() expects parameter 1 to be resource, bool given in /var/www/html/picGPIO.class.php on line 59 [Wed Oct 13 10:53:25.212636 2021] [php7:warn] [pid 650] [client 192.168.0.235:65158] PHP Warning: fwrite() expects parameter 1 to be resource, bool given in /var/www/html/picGPIO.class.php on line 59 [Wed Oct 13 10:53:26.212951 2021] [php7:warn] [pid 650] [client 192.168.0.235:65158] PHP Warning: fwrite() expects parameter 1 to be resource, bool given in /var/www/html/picGPIO.class.php on line 59 [Wed Oct 13 10:53:26.213224 2021] [php7:warn] [pid 650] [client 192.168.0.235:65158] PHP Warning: fclose() expects parameter 1 to be resource, bool given in /var/www/html/picGPIO.class.php on line 19
Rafael Martin Soto - 2021-10-13 18:58:51 - In reply to message 1 from Joan Barns
I think that i found your problem.
See at (Permission denied in...) Apache2 do not have permission to access this files (GPIO PORTS with fopen are as file). Is for security. When you use apache, you run the script as 'apache' user, and is normal that your system need to be protected for execution some scripts. You need to execute the php by CLI (command line, mode text). You cannot to execute with apache. When you execute the script by CLI. Is your own user that executes the script, and then you have permissions to access to more part of your system. You can try to change permissions. may change depending on the system. You will need to perform some tests for sure. You find a lot of help at google. I give you some examples: google.com/search?q=permission+apac ...forums.raspberrypi.com/viewtopic.ph ...good luck!!!!
Rafael Martin Soto - 2021-10-13 19:08:30 - In reply to message 2 from Rafael Martin Soto
AAnother thing.
It is also rare that it works from the second time, but if you look at the thread of the second link that I passed, you will see that it seems that there is something special with apache and permissions. In this case, when handling the hardware so directly, if you continue to have problems, I highly recommend using the CLI environment.
Rafael Martin Soto - 2021-10-13 19:08:33 - In reply to message 2 from Rafael Martin Soto
Another thing.
It is also rare that it works from the second time, but if you look at the thread of the second link that I passed, you will see that it seems that there is something special with apache and permissions. In this case, when handling the hardware so directly, if you continue to have problems, I highly recommend using the CLI environment. |
info at phpclasses dot org
.