I decided I’d like to blog. I have ideas and some are worth sharing; others not so much. I’ll try and keep the latter to myself. However, I thought the writing would be fun, as would the technical challenge of maintaining the server. When Eileen had her music studio, I hosted her website from a relatively low-powered AMD Linux arrangement. Since my blog was going to be only for fun, I decided to run the site from a Raspberry Pi 5. The Pi 5 is a fairly robust little board and I think can be used for a low traffic (friends, relatives, random curious folks) website. Here are some observations and tips from experience. Please note this is not a detailed “how-to” guide. There are lots of resources on the Web on how to execute the various steps I’ve described. I assume you can handle a CLI, have a good frustration/error tolerance, and can pay attention to detail. If you assume CLI stands for Chinese Language Instruction and think “sudo” is “pseudo” misspelled, maybe start with an easier project.
Hardware Purchase Considerations:
- If the Pi is used exclusively for hosting, 4GB is just fine.
- Cooling fan and PCIe hat are essential. I bought an official fan and a Geekworm X1001 NVME peripheral board. Installation of both components is straightforward. I’m also using an official 27 watt power supply.
- There’s quite a bit of chatter about SSDs. I don’t want to get into that. After reading the chatter and looking around, I bought a Silicon Power 512 Gb SSD and after some fiddling, it worked fine. See below for fiddling. The Amazon URL is here.
- I’ll make a case eventually.
- Hardwired Ethernet cable. Absolutely. I saw an arrangement online several years ago for isolating the server from the rest of my local network which is brilliant in its simplicity and does not require a firewall appliance, just a second good-quality router. Read about it here.
Hardware Setup and Prep
- I used Raspberry Pi Imager to write the OS directly into the SSD. Worked just fine. No need for an intermediary SD card.
- Image an SD card as well. Its use will hopefully be brief.
- Start the pi using the SD card. Unfortunately, you will need to do some setup stuff on the card so that the OS is fully functional. Once the OS is running open Terminal. Launch the configuration application by typing
sudo raspi-config
. This is not the same app as the one available through the GUI. Find the advanced option and open the advanced menu. Set the PCIe to function as Gen 3. This stabilized the Silicon Power SSD. - Make sure you’ve saved your changes, shut down the pi, and remove the power cable. Eject the SD and install the SSD.
- Power up the pi again and do the OS setup again, this time on the SSD (sorry.) Launch raspi-config again, and choose advanced. Choose extend SD card. This will allow you to use all of the space on the SSD. Confirm that the pi is running the PCIe at Gen 3 level. If it is not, repeat the above steps to make sure the SSD behaves.
- Set a static IP address for the pi. You must do this to ensure uninterrupted communication with your router. There are a number of different ways of doing this, but I did it through the GUI and clicking on the network connection in the upper right-hand corner of the screen. Advanced Options -> Edit Connections -> Wired connection 1 (or whatever) IPv4 Settings -> Method-> choose manual. I use the address of my router as the gateway, and 255.255.255.0 as the subnet mask.Use whatever static address is appropriate to your local network.
- You must adjust settings on the router that connects to the pi. Each router has different screens, etc but you must complete two tasks. First, identify the pi in the connected devices list. Following your router’s instructions, assign an IP address manually to the pi. You DO NOT want a dynamically assigned IP address. Next, you must do port forwarding so that the pi can communicate with the outside world. Forward ports 80 and 443 (http and https respectively.) Save changes.
A couple of preliminary software things…
- If you don’t have a domain name, get one now. You certainly can run the WordPress installation on your local network using the numerical IP address, but what’s the fun of that?
- Unless your ISP has assigned you a static IP address (unlikely unless you are paying tons of money for service) you will need to have an account with a dynamic DNS host and install their update client. (I use noip.com. I’m pretty happy with them.) Although noip claims this is easy, the documentation is a little hazy in spots. My attempts at clarification here. Many modern routers (my Asus, for example) have the capacity to provide this update function (look for DDNS and set up accordingly). If available on your equipment, it’s a great choice.
Installing WordPress
Phew! Almost there. I scoured the web looking for good instructions. My favorite is here. Clear, well-illustrated, and specific for WordPress. What? Of course it’s specific for WordPress! Well, yes and no. WordPress on Pi is a content manager running in a LAMP environment (Linux Apache MySQL PHP). There are some excellent tutorials on how to install the individual components of AMP, but you either end up doing extra work or having bits and pieces of files and code floating around that need to be cleaned up so that WordPress is not confused.
OK, you’ve followed instructions and WordPress is installed and working. You pop into the Dashboard and you see a red warning on site health– PHP is missing a bunch of modules! This is easily remedied. The Raspberry Pi repository has a different naming convention. For example, trying to install the “curl” PHP module failed. On planet Pi, however, sudo apt install php-curl
worked just fine. So, install all the missing components by prefixing php- before the name before doing the install.
After putzing around for a while, trying to make it so that I didn’t need to specify a subdirectory when accessing the site (i.e., www.electricmammal.com/wordpress rather than www.electricmammal.com), and trying all sorts of things, I ran this in Terminal:
sudo ln -s /var/www/html/wordpress/index.php /var/www/html/index.php
. This created a shortcut link to the index.php file in the wordpress subdirectory. Seems to work just fine…
SSL
I am ashamed to say that I ran my wife’s website unsecured. There’s no excuse for that. It is very easy and free to secure your website, and I only just learned about it. My bad. Let’s Encrypt provides free certificates (https://letsencrypt.org/getting-started/) and certbot (https://certbot.eff.org/instructions?ws=apache&os=snap) provides excellent instructions for installing the certbot service. There’s a short detour to install snap (again, nicely documented in the certbot instructions) and an auto-renew task is installed in cron. There is one tiny gotcha. When setting up certbot, you must specify the domain names to be associated with the certificate. Remember that “example.com” is different from “www.example.com” and associate both domain names with the certificate. Instructions are clear.