Operations 13 min read

Turn a Raspberry Pi Zero W into a Tiny Web Server: Complete Setup Guide

This step‑by‑step guide explains what a Raspberry Pi Zero W is, how to prepare the hardware, flash Raspbian Stretch Lite onto a micro‑SD card, enable SSH and Wi‑Fi, optimise the system, install Nginx, and expose the tiny web server to the Internet using tunnelling tools.

Programmer DD
Programmer DD
Programmer DD
Turn a Raspberry Pi Zero W into a Tiny Web Server: Complete Setup Guide

No.1 What is Raspberry Pi?

Raspberry Pi (RPi) is a credit‑card‑sized single‑board computer designed for learning programming. It runs Linux and, with Windows 10 IoT, can also run Windows. Since its launch it has been popular among hobbyists; despite its tiny size it offers video, audio and full I/O.

1. My interpretation

It is essentially a tiny host that can connect to a monitor, keyboard, mouse, USB drives, etc., and provides many serial ports and GPIO for low‑level hardware access.

2. Common models

Most available boards are 3 B+; they cost about 230 CNY for the bare board. The author sought a cheaper option and found a model for around 100 CNY.

3. Raspberry Pi Zero W

The Zero W is a mini version roughly one‑third the size of a 3 B+. It is extremely small and cute; the article includes a photo comparing it with a pen, a USB Wi‑Fi dongle and a card reader.

Key specifications of the Zero W:

BCM2835 processor, 1 GHz, 512 MB RAM

BCM43438 Wi‑Fi / BT chip

Micro‑USB power and OTG ports

Mini‑HDMI port

Composite video and reset pins

CSI camera connector

Micro‑SD slot for the OS

40‑pin GPIO header

Dimensions: 65 mm × 30 mm

Although it has a single‑core CPU and limited RAM, it can still run a small website comfortably.

4. More Raspberry Pi models

Further models and tutorials are available on the Raspberry Pi Lab website.

No.2 Installing the OS on Raspberry Pi Zero W

1. Preparation

Required items:

16 GB or 32 GB SanDisk micro‑SD card

Standard USB‑type‑A Android cable (not Type‑C)

SD card formatting tool (e.g., SDFormatter)

Image‑writing tool (Win32DiskImager)

Raspberry Pi OS image (download from the official site)

The author uses the “Raspbian Stretch Lite” image – a minimal, console‑only version that saves space and resources. The “desktop” variant includes a GUI but is larger.

2. Download the OS image

After downloading, unzip the ~360 MB archive to obtain a folder containing an .img file (~1.7 GB). If a third‑party image does not contain an .img, additional steps may be required.

3. Write the image to the SD card

Insert the micro‑SD card into a reader, open Win32DiskImager, select the .img, choose the correct device, and click “Write”.

4. Modify the boot partition

The boot partition (≈40 MB) is the only part Windows can see. Inside it:

4.1 Create an empty file named ssh (no extension) to enable SSH on first boot.

4.2 Create wpa_supplicant.conf with Wi‑Fi credentials:

country=CN
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1

network={
    ssid="your_wifi_name"
    psk="your_wifi_password"
}

5. Assemble and power up

Insert the prepared SD card into the Zero W, connect power via the USB cable, and wait for the LED to become steady. Then locate the Pi’s IP address on the router (e.g., 192.168.0.104).

6. System optimisation

6.1 Change apt sources to a domestic mirror (e.g., USTC)

sudo nano /etc/apt/sources.list
# comment existing lines and add:
deb http://mirrors.ustc.edu.cn/raspbian/raspbian/raspbian stretch main contrib non-free rpi
sudo nano /etc/apt/sources.list.d/raspi.list
# comment existing lines and add:
deb http://mirrors.ustc.edu.cn/archive.raspberrypi.org/debian stretch main ui
sudo apt-get update
sudo apt-get upgrade

6.2 Set timezone to Asia/Shanghai

sudo dpkg-reconfigure tzdata

6.3 Enable SSH at boot

Method 1: sudo raspi-config → “Interfacing Options” → enable SSH.

Method 2: add /etc/init.d/ssh start before the exit 0 line in /etc/rc.local.

7. Install Nginx

# Install
sudo apt-get install nginx
# Start
sudo /etc/init.d/nginx start
# Restart
sudo /etc/init.d/nginx restart
# Stop
sudo /etc/init.d/nginx stop

Access http://192.168.0.104 in a browser to verify the Nginx welcome page. The author also deployed a personal blog.

8. Expose the service to the Internet (port‑forwarding)

Use a tunnelling tool such as ngrok or frp. The author tried several services; the ittun ngrok ARM client worked best. Run it inside a screen session so it stays alive after logout.

9. Further possibilities

The Zero W can run many other projects beyond a simple web server; the Raspberry Pi Lab hosts many tutorials for additional ideas.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

Raspberry PiSSHZero W
Programmer DD
Written by

Programmer DD

A tinkering programmer and author of "Spring Cloud Microservices in Action"

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.