• Home
  • blog
  • Powering Raspberry Pi Projects with PHP

Powering Raspberry Pi Projects with PHP

A Raspberry Pi is a brilliant tiny computer that you can power off of a micro USB cable. The most recent model has WiFi, an ethernet port, 4 USB ports and an HDMI port. There’s also a micro SD card slot, which is where the “hard drive” goes.

Electronics stock image

It’s capable of running Raspbian Linux, which is a Debian based Linux distribution. This makes it familiar to Ubuntu users who can then just sudo apt-get install all the things.

Like with any Linux machine, you can install PHP on it and make a website – but we can do so much more than that!


Firstly, we will need a Raspberry Pi. The most recent model has onboard WiFi, which is very useful for easy SSH access. We will also need some electronics equipment. It is a really good idea to obtain a starter kit containing a breadboard, jumper wires, resistors, LEDs and push buttons. You can buy these sorts of kits on adafruit and similar packs can be found much cheaper on Amazon and eBay.


The Raspberry Pi official website has an excellent quick start guide to help you get up and running. Once you have Raspbian Linux running on your machine, you can use this command to install PHP:

sudo apt-get install php5

Alternatively, install PHP7. It’s a bit more complicated, but performs better. This guide explains it well.

General Purpose Input Output (GPIO) Pins

On the corner of a Raspberry Pi board are two rows of metal pins that we can connect electronic circuits to. Some of the pins are grounded, some are 5V, some are 3.3V and most of them are GPIO pins.

GPIO pin map

When a GPIO pin is configured as an output pin, we can tell the Pi to set its voltage to be high (3.3V) or low (0V). This allows us to turn things on and off.

When a GPIO pin is configured as an input pin, we can check to see the voltage on that pin and also detect when that voltage changes. This allows us to read sensors and also detect things like button presses.

There is plenty more that we can use these pins for, such as communication via Serial, i2c or SPI – but for now, this is all we are required to know.

Continue reading %Powering Raspberry Pi Projects with PHP%