On Bookworm 64-bit on a Pi5 8GB, user pi, this works for me (may not be that secure) using pinctrl and php:Note I have modified the apache2 file ownership and restarted apache2
user and group of index.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
Code:
sudo chown -R pi:www-data /var/wwwsudo chmod u+rxw,g+rx-w,o-rwx /var/wwwsudo chmod g+s /var/www
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