Steps:
Install Apache 2
Install PHP 5
A big issue: You really aren't going to want to run Apache as root, but the base setup requires you to be root in order to manipulate the GPIOs. gpio-admin will export them to an area that allows non privileged users access.
Install gpio-admin (https://github.com/quick2wire/quick2wire-gpio-admin)
Add your web server user to the gpio group
Anode of LED is connected to +3v, then a 330 resistor, then to GPIO 4.
Sample blinky LED php script (output only)
- Code: Select all
<?php
shell_exec("gpio-admin unexport 4"); // in the off chance I've left it exported somewhere else
shell_exec("gpio-admin export 4"); // make GPIO 4 ready for use
shell_exec("echo out > /sys/devices/virtual/gpio/gpio4/direction"); // set GPIO 4 mode
shell_exec("echo 0 > /sys/devices/virtual/gpio/gpio4/value");// bring low - will sink LED current
sleep(1);
shell_exec("echo 1 > /sys/devices/virtual/gpio/gpio4/value");//bring high - will turn off LED
sleep(1);
shell_exec("echo 0 > /sys/devices/virtual/gpio/gpio4/value");
sleep(1);
shell_exec("echo 1 > /sys/devices/virtual/gpio/gpio4/value");
sleep(1);
shell_exec("gpio-admin unexport 4"); // unexport the pin. Don't skip this step
?>
Hope this helps someone!