About me

Blog Posts Blog Tags

2021 2020 2019 2018 2017

Log in

Copyright © 2020
Jeffrey Elkner

Configuring a Web Development Server on a Raspberry Pi 4

Powered by Debian

After I finish the one described in this post, I will have three little Raspberry Pi 4 B computers sitting on the top of shelves in my apartment providing me with silent (no moving parts) always on servers for web services, file storage, and software development.

In this post I'll document the process of setting up the newest edition to this collection.

I begin by grabbing the latest of the tested image files from the Tested images page on the debian website. With Debian 11 (Bullseye) now in hard freeze, I'll be installing that version.

I have a 13 year old Acer Aspire One running Raspberry Pi OS that has a built-in SD card slot perfect for this purpose. Since it is running Raspberry Pi OS, it was trivial to install the Raspberry Pi Imager and then use that to write the downloaded debian image to the 512 GB SanDisk Ultra microSD UHS-I Card I got for this purpose.

Raspberry Pi Imager

The processor on the Pi 4 is getting powerful enough that it is nearing the point where it will need a cooling fan. I didn't want any moving parts, and found the Vilros Raspberry Pi 4 Compatible Self Cooling Heavy Duty Aluminum Alloy Case, which has been working very well for me, with no overheating problems.

After putting the freshly flashed micro SD card in the Pi, I need to hook it up only once to a keyboard and monitor to run the initial configuration.

First boot of movies.local

I read that the Debian folks only did this reluctantly, but they enabled root login on the first boot Pi's with no password.

New login on movies.local

Once logged in as the root user, I did the following to configure the machine for remote, headless access:

  1. Create a new user (which in my case is jelkner).
  2. Add the new user to the sudoers groups with # adduser jelkner sudo.
  3. Install the sudo command and bash-completion with # apt install sudo bash-completion.
  4. Edit the /etc/hostname file to set new hostname (which in this case is going to be movies).
  5. Add the new hostname to the localhost line in the /etc/hosts file (so mine became  localhost movies).
  6. Run # apt install avahi-daemon to make the machine discoverable by its hostname.
  7. Reboot.
  8. Test that you can access the new machine with ssh with its hostname ($ ssh jelkner@movies.local).

This all worked, so I moved movies.local to it's new home.

movies.local finds a home

I have two other machines, webdev.local and raspi4.local sitting on top of a book shelve.

webdev.local and raspi4.local

They don't make any noise, and they are always there when I need to copy a file or test out new software.

webdev.local and raspi4.local up close

This machine is going to be, among other things, a web server to serve my movie files. I'm going to use nginx as the web server, which on debian requires only:

$ sudo apt install nginx

To get this:

Welcome to nginx

During the nginx install I got a warning about locale not being configured, and a quick web search took me to this page. When I tried the recommended $ sudo dpkg-reconfigure locales, it said the locales package was not installed, so I ran:

$ sudo apt install locales
$ sudo dpkg-reconfigure locales

And it's all set. The coolest thing about this new web server, and the main reason I set it up, is that in addition to being a useful web development server, I can use it as a media server for all the movies I have in my DVD collection. It is getting increasingly difficult to find computers with DVD drives, so using Handbrake I have been gradually ripping my DVD collection, and putting my movies on this web server:

Movie server screenshot