Last Updated: 3rd Apr 2017
WPTavern: Blog in a Box Project Integrates WordPress with Raspberry Pi
The original Raspberry Pi was released five years ago and the micro computer product line is still going strong. The Raspberry Pi Foundation sold its ten millionth Pi last year and just released the Pi Zero W in February 2017 with built-in WiFi and Bluetooth.
If you are among the millions of Raspberry Pi owners who like to tinker with software, check out Automatticâ€™s new Blog in a Box project. It currently offers the easiest way of installing WordPress onto a Raspberry Pi.
Although RaspberryPi.org has documentation for how to run WordPress as a local website on your Raspberry Pi, its recommended method requires you to install and configure Apache, PHP, and MySQL to create a LAMP web server.
Blog in a Box makes it simpler with a GUI installer that puts everything you need for installing WordPress onto an SD card. It comes bundled with PHP7, Nginx, and the latest version of WordPress. It automatically installs the Blog In A Box WordPress plugin, which provides an interface for the Blog In A Box CLI tool and widgets for SenseHAT readings. It also includes a full Node development environment. The projectâ€™s creators call it â€śa complete system for interfacing Pi hardware with WordPress.â€ť
Blog in a Box enables users to publish data captured by the Raspberry Pi camera and SenseHAT, like photos or temperature readings, to a WordPress site that can be accessed on your local network at bloginabox.local. It is not yet capable of publishing to the web, but John Godley, an Automattic developer who worked on the project, said the team is open to adding this.
â€śPart of the fun of a Pi is having this device in front of you that you can play and experiment with, and we wanted to have WordPress running right there inside the Pi too â€“ it really is a blog in a box!â€ť Godley said.
â€śWe hope that having it local will encourage people to tinker with WordPress and use it to learn programming, or to run experiments in classrooms.â€ť
There are currently no live examples of blogs on the web that are receiving posts from a Raspberry Pi. However, fellow Automattic developer and Pi enthusiast Nick Momrik has created a device called Blog in a Box Paparazzi that extends the project with additional sensors to take a photo when anyone walks past it. His circuit diagram and a full list of sensors and other electronic components are available on GitHub. Itâ€™s one example of how Blog in a Box can be used as a base for other fun use cases.
image credit: Nick Momrik â€“ Blog in a Box Paparazzi GitHub repo
Although the project doesnâ€™t come packaged with functionality that would allow it to work as a livecam, Godley said itâ€™s certainly a possibility.
â€śWe created a system to make it easy to interface the Pi hardware with WordPress â€“ thereâ€™s a plugin and a set of server tools that are all extensible,â€ť Godley said. â€śWith a bit of work a livecam system could be added. If you add the sensor mentioned above you could livestream your cat whenever itâ€™s nearby. Add some different sensors and you can see what affects a plantâ€™s growth in a biology experiment and have the data ready to be viewed through WordPress, add a touchscreen and you have an interactive WordPress-powered display.â€ť
Since the system uses the REST API internally, Godley it wouldnâ€™t be difficult to configure it to send data to a remote WordPress site. The team has looked at the possibility of doing this and may revisit it in the future if thereâ€™s enough interest.
â€śMaking it really easy to set up was a primary aim â€“ we didnâ€™t want people to have to setup MySQL and web servers and all the complexities involved in connecting this to Pi sensors. Just a few clicks and a fully working system is copied to an SD card,â€ť Godley said. â€śOnce you boot your Pi it appears on your local network and can be used immediately.â€ť
The site runs on the local network but the box ensures that WordPress and its plugins stay updated. The ability to run the box without an internet connection is one of the main advantages of Blog in a Box.
â€śThe fact you can run it without an internet connection means it can be used in situations where a remote WordPress may not be appropriate â€” in your home, in schools, etc,â€ť Godley said. â€śIf someone sends WordPress into space on a rocket, then weâ€™d love to hear about it!â€ť
The project is an exciting example of how WordPress can be deeply integrated with various hardware components to automatically capture and publish environmental data in a way thatâ€™s easy to view. Godley and his team at Automattic hope that Blog in a Box will put WordPress into the hands of more like-minded tinkerers. The entire project, including the installer, the companion WordPress theme, and the plugin, are all open source.
â€śAs well as people connecting the real world to their Pi, we hope that just having a full web development environment ready to go will encourage people to tinker with WordPress and try out programming or theming,â€ť Godley said.