Configuring a Web Development Server on a Raspberry Pi 4
April 24, 2021
Configuring a Web Development Server on a Raspberry Pi 4
April 24, 2021

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.

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.

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

Once logged in as the root user, I did the following to configure the machine for remote, headless access:
- Create a new user (which in my case is
jelkner). - Add the new user to the sudoers groups with
# adduser jelkner sudo. - Install the
sudocommand and bash-completion with# apt install sudo bash-completion. - Edit the
/etc/hostnamefile to set new hostname (which in this case is going to bemovies). - Add the new hostname to the localhost line in the
/etc/hostsfile (so mine became127.0.0.1 localhost movies). - Run
# apt install avahi-daemonto make the machine discoverable by its hostname. - Reboot.
- 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.

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

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

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:

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:
