Web server based on Raspberry Pi
Intruduction
Many times I was wondering where I can host simple webpages. As an IT administrator I could have dedicated VM on servers at work, but for many reasons it’s not a good choice. The main on we should not mix our private aims with production environment in our company. So maybe some free VPS in Azure? It could be, but if you run out of free period, there is only a choice between low cost VPS or … server at home. Last choice always sounded exciting for me, but can we have a server without increasing our electricity bill?
Yep, here comes Raspberry Pi, as a computer which has low power consumption and enough good specification to handle simple LAMP server.
I’ve put Raspberry Pi 4 on my wishlist to st. Nicholas, so I got it in December 2019 and decided I will make it my webserver for this blog (yes, this blog is hosted on Raspberry Pi).
My whole kit includes:
- Raspberry Pi 4b (version with 4GB of RAM) – because it was cheap even in the most powerful option.
- Original Raspberry power supply because there are problems with not genuine power supplies.
- The cheapest heat sinks – just to have something, but I’m not sure it will be sufficient.
- SD card – Kingston microSDXC Canvas React 32GB. It was the cheapest with declared write speed more than 70MB/s.
This kit is just to start my adventure with Raspberry and it’s not what I recommend, it’s just what I have for the begining. I got 1,2,3 from online shop botland.com.pl .
This manual will be divided into 3 parts, from unboxing Raspberry to installed WordPress.
Prerequisites
What you will need (besides Raspberry of course!):
- Public IP address – ask your Internet provider about it.
- Access to admin panel of your router – refer to a documentation or contact your Internet provider. You will need it for DHCP settings and port forwarding (PAT).
- Purchased domain with access for modifying DNS records.
Heat sinks
As I know Raspberry Pi 4 is the hottest version in history, so heat sinks are nearly mandatory to avoid throttling. My are the cheapest and I decided to put them on:
- Broadcom BCM 2711 CPU
- Broadcom BCM54213 Gigabit Ethernet controller
- VL805 chip for the USB 3.0 and USB 2.0 ports

Probably it would be good idea to put one more heat sink on the RAM chip (black rectangular between CPU and Ethernet controller/USB chip) but I didn’t order it yet.
Operating system – Raspbian
The most common OS for Raspberry is Rasbian OS based on Debian. It’s well documented and teseted so it will be very reliable choice for our webserver. You can download Raspbian here. Due to lack of micro HDMI cable and capacity of my SD card lite version will be best. If you are not going to run GUI (graphical interface) it will be a good choice for you too.
Installation
Installation process is easy and requires a few simple steps:
- Download the Raspbian image and unzip it to get file with extension *.img
- Download and install balenaEtcher program witch is available for Windows, Linux and MacOS.
- Put in you microSD card
- Run balenaEtcher, choose image (*.img) file, choose sd card and hit Flash! button.

That’s it. You are ready to go BUT if you are not going to use monitor, just like me, don’t disconnect your sd card yet. We will need to enable SSH before first run. From 2016 Rasbian has SSH server disabled by default, so old documentation can be a little confusing.
Configuring SSH server without monitor
In order to do it, open partition from sd card called boot and create an empty file named “ssh” without any extension. During first boot Raspbian will look for this file and enable SSH if the file exist.
Please take into account that Windows is not showing extensions by default. You will need to change this setting in Control Panel -> File explorer options -> View tab -> untick option “Hide extensions for known file types.

Important: Mentioned file will be deleted after first run, don’t worry about it. SSH will remain enabled.
Configuring WiFi without monitor
If you are going to use WiFi, you will also need to make some changes in boot partition. This time we will create a file called wpa_supplicant.conf containing code like below.
country=PL ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev update_config=1 network={ ssid="NETWORK-NAME" psk="NETWORK-PASSWORD" }
Of course remember to update you country code (list of country codes can be found here), network name and network password.
First run
Let’s insert sd card into your Raspberry Pi and turn it on (it starts automatically when you connect power cord). How can we use it headless/without monitor? Of course by SSH, but we need to know the IP address. In most cases you have DHCP server running in your network, probably on a home router. Raspbarry use DHCP by default.
If you have configured your WiFi before, Raspbian would connect after boot. Otherwise you will need to connect ethernet cable. You can find out what is the IP address of Raspberry with one of this two methods:
- Using software which will scan your network for active devices. I can recommend Advanced IP scanner. Assuming your computer is in the same subnet as Raspberry, you will get the list of active devices and the one with MAC address starting from DC:A6:32:xx:xx:xx.

- Check in your DHCP server, probably in your router. There should be a list of DHCP clients. Refer to the documentation of your router because this process can vary depending on the router model.
As you see it is 192.168.1.97 in my case. We will need a program called PuTTY in order to connect. Download Putty (if you haven’t done it already) put the IP address, default port is 22 and click Open. It will prompt you with security alert about the server key. Accept it by clicking yes.

The default user is pi with password raspberry . That’s it, you have connected your Raspberry without a monitor, just like me!
As in many other manuals, I also recommend to firstly update your Raspbian. In order to do it, run this two commands.
sudo apt update
sudo apt upgrade -y
Next time we will configure basic settings and secure our Raspberry.
See you in part 2!
0 Comments