contents
Blogs / Setup your Own Website For Free: Rasberry Pi Tutorial
July 23, 2023 • Matthew Duong • Kubernetes;Self Hosting; Software Engineering • 6 min read
I've created this tutorial especially for those who might not consider themselves to be too technical—marketers, salespeople, recruiters—really, anyone who's ever dreamed of having their own website. You won't need to navigate technical jargon, face hidden costs, or have a degree in computer science to follow along. I've also produced a companion video to supplement this written tutorial. It provides visual, step-by-step instructions to make the process even simpler and more accessible. Direct link to video here: https://www.youtube.com/watch?v=xah1Y4UtJCw
;
This tutorial is broken up into five sections:
For this project, you need:
Recommendation: The Canakit as it includes all the necessary components.
In this tutorial, we'll be using Ubuntu Server(https://ubuntu.com/ ) as our operating system. It's a fantastic choice of Linux distribution due to its widespread support from a vibrant community. It's user-friendly for beginners, and it's also widely used in the industry, which is beneficial if you decide to delve deeper into this field one day. Here's how you can install and set up Ubuntu Server on your Raspberry Pi:
SSH is a protocol that allows you to securely access and control your Raspberry Pi (or any other computer) remotely over a network. It's as if you're sitting right in front of it even though you might be on the other side of the world!
After you've installed the OS, you'll need to connect to your Raspberry Pi from your computer. Here's how you can do this:
Remember, when you're using SSH, you're replacing 'username' and 'password' with the credentials you've previously set. This ensures a secure connection between your computer and the Raspberry Pi.
Kubernetes is a tool that helps manage and scale your website. For the Raspberry Pi, we'll use a lightweight version of Kubernetes called K3s. Here’s what you need to do to install K3s:
curl -sfL https://get.k3s.io | sh -
More information can be found on the official k3s setup guide (https://docs.k3s.io/quick-start )sudo k3s kubectl get nodes
NAME STATUS ROLES AGE VERSION
thegalah-pi Ready control-plane,master 3m v1.21.7+k3s1
kubectl
is a command line interface for running commands against Kubernetes clusters. In simple terms, it's the "remote control" that allows you to manage and interact with your Kubernetes cluster. Whether it's deploying applications, inspecting and debugging resources, or even directly managing cluster resources, kubectl
is the go-to tool for Kubernetes users. To install run this command:
curl-LO"https://dl.k8s.io/release/$(curl-L-s https://dl.k8s.io/release/stable.txt)/bin/linux/arm64/kubectl"&&sudomv kubectl /usr/bin &&sudochmod +x /usr/bin/kubectl
We then need to configure our kubectl command line tool to connect to our k3s setup using this command:
sudo cp /etc/rancher/k3s/k3s.yaml ~/.kube/config
To confirm that the kubectl cli works with our credentials we can run kubectl get nodes
similar to the previous step which should return the same output.
Helm(https://helm.sh/ ) is often described as the package manager for Kubernetes. It simplifies the process of managing and deploying applications on a Kubernetes cluster. Think of Helm as a tool that bundles together all the resources needed for a particular application, allowing you to install, upgrade, and manage the app more efficiently. It's a valuable tool to have, especially when you're dealing with complex apps that have many components. To install helm run this command:
sudo snap install helm --classic
Now that we've successfully installed Kubernetes and Helm, it's time to set up your content management system (CMS). For this guide, we will be using Ghost, a free and open-source headless Node.js CMS. It's designed to simplify the process of online publishing for bloggers.
To deploy Ghost, we'll use the Bitnami/ghost Helm chart. In Helm, every chart represents a deployable app, complete with its configurations, which you can override as per your specific needs. The full list of configurable values for this chart can be found here on artifact hub(https://artifacthub.io/packages/helm/bitnami/ghost )
Let's walk through the steps to configure Ghost using Helm:
curl -o values.yml https://gist.githubusercontent.com/thegalah/8af4588e9f9a6b405c742ceb388e71ec/raw/6d3befdd87dd3ec29bc7a75b073a3c18b99b0906
ghostHost
value with your public ip address (you can find this by searching “what is my ip”).Control + O
Control + X
To install the CMS:
helm repo add bitnami https://charts.bitnami.com/bitnami
helm install cms bitnami/ghost -version19.3.24 -f values.yml --wait--atomic
http://internal-hostname-or-ip:30080
Remember to substitute out the internal-hostname-or-ip with your value.Now that we have set up our website, the final step is to expose it to the internet. To do this, we will configure your router to direct incoming traffic to our Raspberry Pi. You can think of this like your Raspberry Pi is a house, and your router is the postman, delivering any incoming traffic to your house.
Please note, the steps for configuring port forwarding will depend on your router's brand and model. So, you might need to consult your router’s manual or do a quick online search for specific instructions. Nevertheless, here's the high level steps.
Typically, you do this through your web browser using an IP address, often something like 192.168.1.1 or 192.168.0.1.
Here, you will be adding a new rule for port forwarding. You'll need to fill in a few details:
And just like that, your website is now accessible to anyone who enters your public IP address into their browser. They'll be directed to your Raspberry Pi, which is hosting your website. Keep in mind that most residential IP addresses change from time to time. You might consider using a dynamic DNS service to assign a static domain name to your IP, but we'll leave that for another tutorial.
And there you have it! You've successfully transformed your Raspberry Pi into a fully functional web server. Now you're ready to share your website with the world. Congratulations on your achievement!
If you get stuck or need assistance feel free to reach out to me on my discord channel (https://discord.gg/XUeMPrVq ) and I can help provide support to help you get set up.