Self Hosted

## Metadata
- Author: [[jjj.blog]]
- Full Title: Self Hosted
- Category: #articles
- Document Note: ---
tags:
- SelfHosting
- RaspberryPi
- WordPress
- HomeServer
Author: jjj
Source: jjj.blog
Reference: None
date created: 2024-09-10 17:00
---
# Title: Self-Hosting WordPress on Raspberry Pi 4: Achieving Independence and Autonomy
## Table of Contents:
- [Summary](#summary)
- [Main Content](#main-content)
- [Notes](#notes)
- [References](#references)
- [Paraphrase](#paraphrase)
- [Newsletter](#newsletter)
- [Action Items](#action-items)
- [Hypotheses](#hypotheses)
- [Methodology](#methodology)
- [Questions](#questions)
- [Future Research](#future-research)
- [Implications](#implications)
- [Logical validity](#logical-validity)
- [Conclusion](#conclusion)
## 📝 Summary:
In this blog post, jjj shares their experience of transitioning from cloud hosting to self-hosting multiple WordPress blogs on a cluster of Raspberry Pi 4’s in their basement. Motivated by the desire for independence, autonomy, and reduced costs, jjj details the technical setup, challenges, and benefits of running their own server infrastructure. The post also highlights the various tools used, such as Mail-in-a-Box for email management and Caddy for automatic TLS certificates, while reflecting on the broader goal of self-sufficiency in web hosting.
## 📖 Main Content:
jjj begins by explaining their journey to self-host their WordPress blogs on a Raspberry Pi 4 cluster. Tired of paying $100/month in hosting fees, they wanted to own their infrastructure and data. After setting up a network at home and acquiring hardware, jjj now manages several services, including DNS, email, static websites, and WordPress sites for friends and family.
The post breaks down the current setup, which includes Raspberry Pi 4’s running Ubuntu, Docker containers for services like GitLab and WordPress, and a Unifi network for connectivity. jjj discusses challenges like adapting Mail-in-a-Box for ARM64 architecture and highlights the learning experiences gained through running their own internet service (WISP) before upgrading to fiber.
Key components of the setup include:
- **Raspberry Pi 4 Cluster**: A dedicated unit with 8GB RAM and 1TB SSD for each Pi, running independent Ubuntu installs for different services.
- **Mail-in-a-Box**: Handles DNS and email services, modified to run on ARM64.
- **Caddy**: Automatically issues and renews TLS certificates for WordPress multisite installations.
- **GitLab EE**: A self-hosted version controlling the deployment of all custom code and projects.
In addition to the technical setup, jjj reflects on the personal motivations behind this project—control over data, self-sufficiency, and learning. They acknowledge the risks but find the trade-offs worth it for the sense of independence.
### 🗒️ Notes:
- jjj self-hosts WordPress blogs on Raspberry Pi 4’s in their basement.
- The primary motivation was to reduce hosting costs and gain autonomy over infrastructure.
- The setup includes Mail-in-a-Box for DNS and email, GitLab for code management, and Caddy for TLS certificates.
- A Unifi network provides connectivity, and the cluster includes multiple Raspberry Pi 4’s with independent Ubuntu installs.
- Challenges included adapting software for ARM64 and managing power constraints.
- jjj values the learning and independence gained from this setup, despite the risks involved.
## 📖 References:
- None explicitly cited in the article.
## 🗣️ Paraphrase:
1. jjj explains that after years of paying for external hosting, they decided to set up their own infrastructure using Raspberry Pi 4’s to host WordPress blogs, manage DNS, and run email services. This setup offers them the independence and control over their data they desired, while also eliminating the $100 monthly hosting fee.
2. In their basement, jjj runs four Raspberry Pi 4’s in a rack-mounted unit, each responsible for different services such as DNS, email, and WordPress hosting. The system also includes a self-hosted GitLab instance, which controls deployments and backups, making the entire operation more efficient and cost-effective.
## 📰 Newsletter:
📡 Thinking about self-hosting your WordPress blog? jjj has taken their WordPress hosting into their own hands, running a cluster of Raspberry Pi 4’s right from their basement! By handling DNS, email, and web hosting all on personal hardware, they’ve not only cut down on hosting costs but gained full control over their data. This DIY setup uses tools like Caddy for automatic TLS certificates and Mail-in-a-Box for email services. For those intrigued by self-sufficiency and tech autonomy, this is an inspiring example of what's possible! #SelfHosting #RaspberryPi #WordPress
## ✅ Action Items:
As a Developer Advocate in open-source, this article aligns with my goals of promoting independence, sustainability, and education in web hosting and WordPress. jjj’s journey into self-hosting exemplifies the power of open-source solutions and could serve as a valuable case study for encouraging new contributors to explore self-sufficiency in the WordPress ecosystem. I can use this to highlight alternative approaches to hosting while advocating for more accessible infrastructure and educational content around self-hosting.
## 🧪 Hypotheses:
- Self-hosting using Raspberry Pi hardware can significantly reduce costs for small-scale WordPress sites while maintaining reliability.
- The success of self-hosting setups like jjj’s will encourage more developers to explore hosting alternatives, leading to more contributions to open-source hosting tools.
### 📊 Methodology:
To validate these hypotheses, a survey could be conducted among users who have transitioned from traditional hosting to self-hosting. Comparing costs, uptime, and overall satisfaction levels could provide insights into the viability of self-hosting on Raspberry Pi clusters.
### ❓ Questions:
- What are the long-term implications of managing self-hosted infrastructure in terms of time and maintenance?
- Could this model of self-hosting be scaled to support larger websites or organizations?
### 🔮 Future Research:
Future research could investigate the scalability of Raspberry Pi clusters for more demanding web applications and how self-hosting impacts security. Additionally, studying the adoption rates of self-hosting solutions among small businesses and hobbyist developers could reveal trends in the hosting market.
### 💡 Implications:
If self-hosting proves to be a cost-effective and reliable alternative to traditional hosting, it could empower more individuals and small businesses to take control of their web infrastructure. This has broader implications for data sovereignty and independence in the tech space.
### ✅ Logical validity:
The article presents a well-reasoned argument for self-hosting as a way to gain autonomy over web infrastructure. jjj supports their decision with practical examples of cost savings and learning experiences. The tone is lighthearted and personal, yet technically detailed.
**Strong Reasoning Identified**:
- **Causal Reasoning**: The author clearly connects their decision to self-host with the desired outcomes of cost savings and independence.
- **Appeal to Facts/Evidence**: jjj provides detailed insights into the setup and challenges faced, making the case for self-hosting more compelling.
### 🎯 Conclusion:
jjj’s journey into self-hosting their WordPress sites on Raspberry Pi 4’s demonstrates the possibilities for independence, cost savings, and learning through DIY web infrastructure. By managing every aspect of hosting—from DNS to email and web content—jjj showcases the potential of open-source tools in empowering individuals to take control of their digital presence. This article highlights the trade-offs and rewards of self-sufficiency in hosting.
- Document Tags: [[hosting]] [[wordpress]] [[wordprss]]
- Summary: The author self-hosted their WordPress blog and other websites on Raspberry Pi 4's in their basement to achieve independence and autonomy while saving on hosting fees. They manage DNS, email, GitLab, WordPress sites, and network infrastructure using Raspberry Pi's and Docker containers. The setup includes Unifi gear, Caddy Server for TLS certificates, and future plans for improved network monitoring and expansion.
- URL: https://jjj.blog/2024/05/self-hosted/
It’s taken about-a-million tiny steps, but as of this moment (2 May, 2024 07:42 UTC-6) this WordPress blog (jjj.blog) and a bunch of other blogs for friends & family are all ~~calling from inside the house~~ running on a cluster of Raspberry Pi 4’s in a server rack in my basement.
#### Why did I do this?
Aside from the obvious – pride, vanity, education and just-wanting-to – what I really wanted was independence & autonomy. I wanted to break free from paying +/-$100 USD per month in hosting fees for a service that I could provide for nearly $0 (once the network was in place anyways).
I was essentially paying $1200 per year to have a playground of virtual machines to keep 2 of my favorite WordPress plugins stable (WP Multi Network & LudicrousDB) when I could containerize them on my own hardware for nothing.
I wanted to backup & upgrade my servers more easily.
I wanted to own my own infrastructure like I own my own data.
There is a lot that goes into hosting your own website if you want to do it beginning to end, so heeeeeeeere’s:
#### The current setup
I’ve used this for quite a while on a Linode but now it’s running on a dedicated Raspberry Pi 4 with a whopping 8GB of RAM and 1TB SSD. This does a bunch of stuff, but most importantly are Name Servers and Email.
It is responsible for handling all of the necessary DNS, including the authoritative name servers at `ns1.jjj.domains` and `ns2.jjj.domains` respectively. All of my domains use these (and the domains of friends I host here).
It also manages all of the ins & outs of email (including alerts) and includes [Roundcube](https://roundcube.net/) which is nice to have for managing accounts that don’t need to be frequently accessed (using IMAP) from a computer or phone.
I use it to *easily* host some static sites that don’t need WordPress, as well as Nextcloud for *slowly* weening off of Apple iCloud.
Mail-in-a-Box is mostly python, and doesn’t support ARM64 directly (with the variant of Ubuntu Linux that it requires) so I run a very-slightly modified fork and have contributed a few minor improvements here & there.
##### Static IP & Reverse DNS
Between March 2018 and January 2024, I ran my own [WISP](http://wispy.io) (with help from some friends) so that our neighborhood of about 30 homes could have internet access. That meant I had access to a few static IP addresses, and I used 2 of them to separate the name servers from the web domains being served. (That was an awesome learning experience too that I will blog more about later.)
As of January, our neighborhood now has 1GB up/down symmetrical fiber piped right into our homes from [Edge Broadband](https://edgebroadband.com), and for a little bit extra each month they’ve provided me with a dedicated IP and rDNS to `jjj.domains`. This took a little bit of work on their end (a new IP address pool, etc…) and it shows (to me) that they understand their customers’ needs are varied & sometimes even a little special.
Because they only offer a single static IP, I have one remaining 1GB Linode (running Alpine Linux) running as a jump server between DNS requests and serving actual content, but that will go away eventually (I hope!)
##### Unifi Network (Dream Machine Pro SE)
Edge Broadband’s static IP enters the LAN through a [UDM Pro SE](https://store.ui.com/us/en/pro/category/all-unifi-cloud-gateways/products/udm-se), and I use some good’ol unsexy port-forwarding to send requests to one of four Raspberry Pi 4’s:
1. Mail-in-a-Box on a bunch of ports
2. GitLab on a few ports (at [jjj.software](http://jjj.software), more on this below)
3. WordPress 1 on a fancy hidden port (at a bunch of domains)
4. WordPress 2 on a different fancy hidden port (at other domains)
There are some firewall rules here to prevent subnets from reaching each other, as well as each Pi running its own instance of [UncomplicatedFireWall](https://en.wikipedia.org/wiki/Uncomplicated_Firewall) which I’ll touch more on later too.
I’m a big fan of Unifi gear. We use(d) it for our WISP and our house for WiFi, and I have a separate UNVR Pro running Protect and a UNVR4 setup for network attached storage.
[Unifi Network](https://www.ui.com/download/releases/network-server) has become an extremely cool piece of software. In the past 5 years they’ve added a ton of pro’ish features while managing to keep the interface feeling light & fast. It’s possible to run it virtually (or on your own hardware) but their hardware is better than anything I’d configure, plus it’s nice not to really need to think about that at all.
##### Raspberry Pi 4’s
Yes, I’m sure I’ll get 5’s eventually, but they aren’t really necessary yet, at least not for WordPress or the web traffic I normally see.
I have 4 of them side-by-side in a single rack-mounted unit with a total of 6 available. It’s an early-access-only version of what is now Ubiquiti’s [Toolless Mini Rack](https://store.ui.com/us/en/pro/category/accessories-rack-mount/products/toolless-mini-rack) that was never available to the general public for sale, and I also have a dedicated PDU and a 16 port PoE switch that powers the Pi’s and their SSD’s. This is a little bit risky when it comes to available power, but so far so good and I do have some headroom (though not very much).
These Pi’s aren’t setup as a [Bramble](https://www.jeffgeerling.com/blog/2015/how-build-your-own-raspberry-pi-cluster-bramble), even though that’s super cool & compelling. I have mine setup as 4 separate appliances, each with their own Ubuntu installs. Mail-in-a-Box doesn’t support [Noble Numbat](https://ubuntu.com/blog/ubuntu-desktop-24-04-noble-numbat-deep-dive) yet, but I’m certain it will soon.
GitLab EE & WordPress (nightly) are running inside a suite of Docker containers alongside their relative required projects (MySQL, PHP, Memcache, etc…) – GitLab also doesn’t natively support the Pi’s ARM64 architecture, but thankfully [someone maintains a fork that does](https://github.com/zengxs/gitlab-arm64).
##### GitLab EE
Everything that’s running on the Pi’s is also backed-up & deployed from this self-hosted GitLab. I also keep mirrors of the WordPress plugins I’ve authored and a fork of WordPress that I’m writing this post from inside of there. I hadn’t intended to go to deep into GitLab here, but it really is a key component for me to manage all of this stuff.
And I have nothing against Microsoft or GitHub; I use them everyday for work, more than I use GitLab for home, but remember: independence & autonomy.
##### WordPress (1 & 2)
A long time ago I decided to run a fork of WordPress for personal use, and named it “Publicious” – I love the name, but it’s a mouthful to pronounce and I got sick of paying for the domains so I’ve retired that idea for now. (Someone out there noticed that and bought “publicious.org” right away, I’m assuming hoping I’d reused an admin password and would blindly try to login to it.)
Anyways, Publicious has been boiled down to:
* a custom PHP boot-loader in front of WordPress (that includes configuration files for MySQL, Memcache, LudicrousDB, and WordPress constants)
* all of the drop-in plugins, specifically sunrise.php for multi-network
* time.php NTP endpoint
* concat.php for combining CSS & JS requests
* cron.php for system events
* a custom index.php
* a local avatar to reduce Gravatar requests
* a buuuuuuuuunch of plugins
Keeping all of this inside of GitLab makes it relatively easy to deploy & rollback, though I’m tempted to ditch it and use vanilla WordPress more here now thanks to all of the work that’s gone into stability & fatal error detection.
I have two Raspberry Pi’s load balanced just in case of a failure, but so far the second one hasn’t been necessary so I may temporarily decommission it to have 1 fewer thing to maintain.
##### Caddy Server
I’m running Caddy in a few different Docker containers, but ultimately the point of it is best said using their own words:
> By default, Caddy automatically obtains and renews TLS certificates for all your sites.
>
> [https://caddyserver.com](https://caddyserver.com/)
That means, for me, every domain inside of this WordPress Multi-Site/Network/Domain install will always automatically have TLS deployed for it, and it happens so fast you almost can’t even tell even if you’re looking.
This required setting up a special endpoint that Caddy can use to perform a very-fast lookup of whether or not a domain exists inside of WordPress for that request (inside of the `wp_blogs` database table using the `get_site_by_path()` function) which responds with a 200 header if yes and 404 header if no – 200 issues the cert and 404 doesn’t. Easy!
#### What’s next?
Improved network monitoring. Unifi Network includes some already, and it is fine enough, but I will feel more-better when I have a Raspberry Pi whose only job is to report back and tell me that I did or did-not leave UFW disabled or ports open, etc…
I would like to use ProxMox & network boot to reduce some of the manual’ness of configuring these Pi’s.
I’d like a second static IP to cut out that last Linode.
I need bigger SSD’s to move more stuff into Nextcloud, as well as for all of the media that is stored from all of the WordPress sites in this install.
I might setup a dynamic DNS service for the off-chance this static IP stops being static.
#### That’s all?
Yep. I just needed to be my own ISP & offer bargain-basement web hosting, fork a bunch of stuff to run custom code on unsupported hardware, and contribute to about 20 different open source projects in my “sPaRe TiMe” over the course of like 10 years, plus convince my new ISP to bend their rules for me to have reverse DNS.
I think/hope that as more people move to self-hosting, more open-source projects will emerge to make this more of a turn-key experience.
It’s liberating – though, risky – and I can feel the collective eyes of friends & colleagues who also (like I do) care immensely about the security of the web and our shared interests not being super fond of the idea of me exposing part of my home network to the web, but… from my perspective… and for me being me, it’s a new twist on a bunch of old problems, and I’m learning & growing & am better because of it.
Also, I really do believe it *should be easy & possible* for all of us to run our own WordPress (and BuddyPress) on any hardware and have it accessible to everyone everywhere.
I’ll leave comments open for a bit! 💗, Self Hosted, jjj.blog, 01hwxb0y8mbsatk6mgvpm26fge.