Drupal on a single Raspberry Pi
This project is an offshoot of the Rasbperry Pi Dramble project, which helps install Drupal on a cluster ('Bramble') of Raspberry Pi 2 computers.
This playbook/project makes setting up Drupal on a single Raspberry Pi a very easy/simple operation.
Drupal requires as good a Raspberry Pi as you can afford. While Drupal will run okay on any Raspberry Pi, it's best to use a B model 2 or model 3 (both have a snappy four-core processor and 1GB RAM).
Once you have your Raspberry Pi and a good microSD card (the fastest/best one you can get—see microSD Card Benchmarks!), you will need to do a few things to set up the Raspberry Pi and get it ready to run the Drupal installation playbook.
These directions assume you're working directly on your Raspberry Pi, running Raspbian, with a keyboard and monitor attached:
- Download the latest 'Raspbian' image from the Raspberry Pi Downloads page†.
- Follow the image installation guide to transfer the image to your microSD card:
1. Unmount the microSD card:
diskutil unmountDisk /dev/disk2
2. Write the image to the microSD card:pv yyyy-mm-dd-raspbian-jessie.img | sudo dd of=/dev/rdisk2 bs=1m
- Once Raspbian is loaded on the card, insert the card in your Pi, and plug in your Pi to boot it up.
- Boot up the Raspberry Pi. Once booted, open the "Raspberry Pi Configuration" tool in Menu > Preferences. 1. Click the 'Expand Filesystem' option in the System tab. 2. Click OK, then reboot the Raspberry Pi.
- Once rebooted, connect the Pi to your local network either via WiFi or wired ethernet.
- Open the Terminal application (in the launcher or in Menu > Accessories > Terminal).
- Install Ansible via
pip
:sudo apt-get update && sudo apt-get install -y python-dev python-pip && sudo pip install ansible
- Test the Ansible installation:
ansible --version
(should output the Ansible version).
† If you plan on using your Pi as a headless Drupal server, you don't need all the extra software included with the default Raspbian image. I recommend you use the official 'Raspbian Lite' image instead; see the next section.
These directions assume you're working either directly on your Raspberry Pi, running Raspbian Lite, or remotely logged into the Pi via SSH:
- Download the latest 'Raspbian Lite' image from the Raspberry Pi Downloads page†.
- Follow the image installation guide to transfer the image to your microSD card:
1. Unmount the microSD card:
diskutil unmountDisk /dev/disk2
2. Write the image to the microSD card:pv yyyy-mm-dd-raspbian-jessie-lite.img | sudo dd of=/dev/rdisk2 bs=1m
- Once Raspbian Lite is loaded on the card, insert the card in your Pi, and plug in your Pi to boot it up.
- Boot up the Raspberry Pi. Once booted, log in (default username is
pi
and default password israspberry
), and runsudo raspi-config
. 1. Highlight 'Expand Filesystem' and hit return. 2. Scroll down to 'Finished', hit return, and reboot the Raspberry Pi. - Once rebooted, connect the Pi to your local network either via WiFi or wired ethernet.
- Log back in (either on the Pi directly or via SSH).
- Install Git and Ansible via
pip
:sudo apt-get update && sudo apt-get install -y python-dev python-pip git && sudo pip install ansible
- Test the Ansible installation:
ansible --version
(should output the Ansible version).
You need to download this repository to the Pi and run the included playbook to install and configure everything.
- Clone the
drupal-pi
project:git clone https://github.com/geerlingguy/drupal-pi.git && cd drupal-pi
- Copy
example.config.yml
toconfig.yml
andexample.inventory
toinventory
. - Install required Ansible roles:
sudo ansible-galaxy install -r requirements.yml
- Run the Ansible playbook:
ansible-playbook -i inventory -c local main.yml
After a few minutes, the playbook should complete successfully, and you should have Drupal running on your Raspberry Pi, accessible via http://localhost/
To be able to access the site from other computers on your network (e.g. by accessing http://www.drupalpi.dev/
, add an entry to your local hosts file like [ip-of-raspberry-pi] www.drupalpi.dev
.
You can run the Ansible playbook from another host (instead of from within the VM—this also allows you to do everything without installing pip
and ansible
on the Raspberry Pi itself!).
- Change the
inventory
file to use the Pi's IP address instead of127.0.0.1
. - Make sure you have your SSH private key configured for the
pi
account on the Pi (I usessh-copy-id
to copy my ID to the Pi). - Install required Ansible roles:
sudo ansible-galaxy install -r requirements.yml
- Run the Ansible playbook:
ansible-playbook -i inventory main.yml
Note: If you have a headless Raspberry Pi and would like to find it's IP address, one way of doing so is to use a tool like Fing).
If you need to update Drupal Pi, do the following:
- cd into the project directory:
cd /path/to/drupal-pi
- Pull the latest changes:
git pull
- Update all required Ansible roles (and install new ones):
sudo ansible-galaxy install -r requirements.yml --force
- Run the Ansible playbook:
ansible-playbook -i inventory -c local main.yml
Note: Remove -c local
if running from another host.
There is a reset.yml
playbook included that will reset the environment so you can install a fresh copy of Drupal. To run the playbook, enter the following command in the same directory as this README:
ansible-playbook -i inventory -c local reset.yml
Note: Remove -c local
if running from another host.
After it finishes resetting the environment, you can run the main.yml
playbook again to rebuild the Drupal site.
This project was started in 2015 by Jeff Geerling, author of Ansible for DevOps.