Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 5237

General discussion • Re: PHP Calling Pinctrl in shell_exec different in browser from command line

$
0
0
On Bookworm 64-bit on a Pi5 8GB, user pi, this works for me (may not be that secure) using pinctrl and php:

Code:

<!DOCTYPE html><html><head><meta charset="UTF-8" /></head><body><?phpif(isset($_POST["on"])) {$result=shell_exec('pinctrl set 21 op dh');}if(isset($_POST["off"])) {$result=shell_exec('pinctrl set 21 op dl');}?>Test using pinctrl GPIO21<br><form method="POST">  <input type="submit" value="On" name="on" /><p>  <input type="submit" value="Off" name="off" /></form></body></html
Note I have modified the apache2 file ownership

Code:

sudo chown -R pi:www-data /var/wwwsudo chmod u+rxw,g+rx-w,o-rwx /var/wwwsudo chmod g+s /var/www
and restarted apache2
user and group of index.php:

Code:

pi@pi64bk:/var/www/html $ ls -lah-rw-r--r-- 1 pi www-data  394 Feb 20 10:14 index.php

Statistics: Posted by neilgl — Tue Feb 20, 2024 10:17 am



Viewing all articles
Browse latest Browse all 5237

Trending Articles