How to turn a Raspberry into a web server

Truth be told, servers are expensive, incredible expensive, making it impossible to test out simple ideas. But what if I told you that you can turn a Raspberry Pi into a web server?

As you may know, a Raspberry Pi is a small computer that can be used for many things. One of the most common uses is to turn it into a web server. In this post, I will show you how to do it.

Requirements

*Optional

Raspberry Pi

Step 1: Set up the Raspberry Pi

The first thing you need to do is set up your Raspberry Pi. In my case I want to use the Pironman case and boot from an SSD. The first thing to do is to ensemble the case and connect the SSD to the Raspberry Pi.

Raspberry Pi

You can follow the instructions that come with the case, is not that hard. Once you have the Raspberry Pi in the case and the SSD connected, its time to download the Raspberry Pi Imager. You can download it from here.

Raspberry Pi

Step 1.5: Boot from SSD

If you want to boot your Raspberry from an SSD, you can follow these steps:

  1. Install the bootloader (select the family according the gen of your Raspberry). You need to install it in your MicroSD and boot the Raspberry. The LED will turn green when it’s done, or if you plug the HDMI, the whole screen will turn green.

    Raspberry Pi

  2. Now you have to install the OS in the SSD. You can do this by selecting the OS and the SSD. In our case, Raspberry Pi OS Lite will be enough, just make sure you select the 64-bit version.

    Raspberry Pi

Step 3: Connect to the Raspberry Pi

Once you have the Raspberry Pi set up, you need to connect to it. You can do this by connecting the Raspberry Pi to your router using an Ethernet cable. Now you need to find the IP address of the Raspberry Pi. You can do this by logging into your router and looking for the Raspberry Pi in the list of connected devices, or manually from the Raspberry Pi.

Once you have the IP address, you can connect to the Raspberry Pi using SSH. You can do this by opening a terminal and typing the following command:

1
ssh <username>@<ip-address>

You will be prompted to enter the password for the Raspberry Pi. Once you have entered the password, you will be connected to the Raspberry Pi.

So now your Raspberry Pi is set up and connected to the internet, now you have to open your local network to the world.

Step 4: Open your local network to the world

You have to access your router (usually its on http://192.168.1.1/) and configure a static IP for your Raspberry Pi.

This steps depend on your router, but usually you have to go to the LAN settings and assign a static IP to the Raspberry Pi.

Once you have the static IP, you have to open the ports 80 and 443 to the Raspberry Pi. This is usually on the NAT settings of your router. You have to assign the ports to the static IP of the Raspberry Pi (or the device itself depending on your router).

Step 5: Setting up your infrastructure

Now it will depend on your needs. In my case, I want to use kubernetes to deploy my applications.To do so you have to install K3s which is a lightweight kubernetes distribution ideal for our Raspberries.

You can install it by running the following command:

1
curl -sfL https://get.k3s.io | sh -

Once is installed, you have to modify one file, run the following command:

1
sudo nano /boot/firmware/cmdline.txt

And insert the following line at the end of the file:

1
cgroup_memory=1 cgroup_enable=memory

Now reboot the Raspberry Pi and you are ready to go.

1
sudo reboot

Step 6: Deploy your applications

Now you can deploy your applications to your Raspberry Pi K3 cluster. It should be accessible from the internet.

Bonus: Add more clusters

If you want to add more clusters to your infrastructure, you can do so by following the same steps. Just make sure you assign a different IP to each cluster and open the ports on your router. And when installing K3s, you have to specify the IP of the master node.

The value to use for K3S_TOKEN is stored at /var/lib/rancher/k3s/server/node-token on your master node.

1
curl -sfL https://get.k3s.io | K3S_URL=https://<myserver>:6443 K3S_TOKEN=<mymasternodetoken> sh -
, ,
© 2025 Daily Geek All Rights Reserved.
Theme by hiero