Drupal Development on a Raspberry Pi

It’s possible to develop Drupal websites on a Raspberry Pi, and the performance is pretty good considering the specs of this sub $75 computer.

While I expect no professional Drupal developers are using a Raspberry Pi as their primary development environment, everyone starts somewhere. If a computer like a Raspberry Pi is all someone has, they can begin a Drupal career and someday earn, at least, an hourly rate equal to the cost of a Raspberry Pi.

This post details the steps to install DDEV, Docker, and a Drupal 9 website. DDEV is an open source tool that makes it dead simple to get local PHP development environments up and running within minutes. You can follow the written steps and watch along with the video below.

NOTE: I wrote this post many months ago but decided not to publish it. Running Drupal via DDEV requires a 64-bit OS, and Raspberry Pi OS’s 64-bit version has been stuck in beta for a few years. In my experience, alternative 64-bit operating systems available for the Pi were not stable enough to recommend. Yesterday, the 64-bit version of Raspberry Pi OS was released. I successfully retested the installation steps in this post with the 64-bit OS. It’s time to publish.

Requirements

  • Raspberry Pi 400 or Pi 4 B with minimum of 4GB RAM
  • Micro SD
  • Desire to learn

The steps below will install DDEV, Docker and a Drupal 9 website.

64-bit OS

A 64 bit OS is required to install DDEV. Start by downloading a Raspberry Pi OS 64 image to a Micro SD with Imager. If you are not familiar with this process, you can learn more on the Raspberry Pi website.

Pi Imager now includes Raspberry Pi OS 64-bit

After booting your Pi with the new Micro SD, complete the setup process. Reboot the Pi.

Verify your packages are up to date.

sudo apt update
sudo apt upgrade

Install Docker and DDEV

Install Docker and docker-composer

sudo apt-get update && sudo apt-get install -y docker.io docker-compose

Update your permission to run Docker:

sudo usermod -aG docker $USER

Reboot:

sudo reboot

Verify Docker is running by running the hello-world app:

docker run hello-world

Install required packages:

sudo apt-get install libnss3-tools xdg-utils

Install DDEV using install script:

curl -LO https://raw.githubusercontent.com/drud/ddev/master/scripts/install_ddev.sh && bash install_ddev.sh

Verify DDEV is installed:

ddev --version

Configure Drupal 9 Website

Create folder for the Drupal website:

mkdir drupal9
cd drupal9

Configure and start DDEV:

ddev config --project-type=drupal9 --docroot=web --create-docroot
ddev start

Install Drupal and drush:

ddev composer create "drupal/recommended-project"
ddev composer require drush/drush
ddev drush site:install -y

Launch website as administrator:

ddev drush uli
ddev launch

Next Steps

USB SSD Drive – For faster, more reliable drive access, consider running your Pi from a USB SSD instead of the Micro SD card. You can find instructions for setting this us at Tom’ Hardware.

DDEV – If you new to DDEV, you learn more at DDEV-Local Documentation.

Reference Video

References

Watch: DDEV-Local on ARM64 Raspberry Pi

DDEV Drupal Quick Setup

Use SSH Keys on a Remote Computer

SSH Agent Forwarding is used to share ssh keys with a remote computer.

Use Case

You SSH into a remote computer, and from there, you need to access a remote server that requires your ssh keys. A typical example of this is cloning a repository on a remote computer. However, you don’t want to copy your local ssh keys to the remote server or create new ones. SSH Agent Forwarding allows a remote computer to use your local SSH keys without leaving your credentials on the remote computer.

Basic Concepts

SSH Agent: A program that keeps track of identity keys and passphrases. The SSH Agent is needed for Agent Forwarding. You can use SSH Agent to remember your SHH passphrase; therefore, you don’t need to type your passphrase each time you use your private key. This post does not cover passphrases.

SSH Agent Forwarding: A feature of SSH that allows an SSH server on the remote computer to use the client’s SSH Agent to access SSH keys on the local computer.

SSH Agent Setup Steps:

  1. Start the SSH Agent on your local computer
  2. Add your ssh leys to the agent
  3. Connect to the remote computer via SSH with forwarding turned on

Demonstration

In the example below I will share SSH keys with a remote computer to access a git repository.

  1. Verify the local computer has SSH access to Github using the ssh -T command.
  1. SSH into the remote computer and verify it does not have access to Github. On the remote computer, we will receive a ‘permission denied’ error from Github because the remote computer does not have my SSH credentials.
  1. On the local computer, check if the SSH Agent is running by displaying the $SSH_AGENT_ID environment variable. If it’s running, the agent process ID will be displayed. If it’s not running, blank will be returned.
  1. On the local computer, start the SSH Agent using the eval command. On success, the Agent process ID will be displayed.
  1. On the local computer, list SSH identifies assigned to the agent using ssh-add -l. Since the SSH was just started, no identities will be returned.
  1. Add the SSH identities, aka SSH keys, defined in the ~/.ssh folder with ssh-add. The ssh-add command will add all identified in the ~/.ssh folder by default. To add a specific identity, use the -T parameter.
  1. Verify the identities were add by running ssh-add -l
  1. Reconnect to the remote computer with SSH and use the -A parameter to set Agent Forwarding on.
  1. On the remote computer, verify Github is now accessible.

Additional SSH Tip

SSH Config

You may have noticed in the demonstration above, the ssh command does not include an IP address or user name. ssh pi3b vs. ssh pi@192.168.1.10. This is accomplished by using an SSH config file in ./ssh/config:

Host pi3b
    HostName 192.168.1.10
    User pi

SSH Config can also automatically set Agent forwarding for an SSH connection, removing the needs to pass -A with the SSH command.

Host pi3b
    HostName 192.168.1.10
    User pi
    ForwardAgent yes

You can learn more about SSH Config in my post Easier SSH with Config.