Operations 13 min read

How to Set Up Raspberry Pi Zero W: From OS Installation to Remote Access

This step‑by‑step guide explains what a Raspberry Pi Zero W is, how to flash Raspbian onto a micro‑SD card, configure Wi‑Fi and SSH, optimize the system, install Nginx, and expose the device to the internet using ngrok, all with clear images and code snippets.

Java Backend Technology
Java Backend Technology
Java Backend Technology
How to Set Up Raspberry Pi Zero W: From OS Installation to Remote Access

1. What is a Raspberry Pi?

Raspberry Pi (RPi) is a credit‑card‑sized micro‑computer designed for learning programming. It runs Linux and, with Windows 10 IoT, can also run Windows.

Despite its tiny size, it offers video, audio, GPIO pins, HDMI, USB, and more.

Key specifications of the Raspberry Pi Zero W

BCM2835 processor, 1 GHz, 512 MB RAM

BCM43438 Wi‑Fi / Bluetooth chip

Micro‑USB power and OTG ports

Mini‑HDMI port

Composite video and reset pins

CSI camera interface

Micro‑SD card slot for the OS

40‑pin GPIO header

Dimensions: 65 mm × 30 mm

2. Installing the system on Raspberry Pi Zero W

Preparation

You will need:

16 GB or 32 GB SanDisk micro‑SD card

A standard USB‑type‑A data cable (not Type‑C)

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

Image writing tool (Win32DiskImager)

The Raspberry Pi OS image (download from the official site)

We use the Raspbian Stretch Lite image – a minimal, console‑only version.

1️⃣ Download the OS image

After downloading, unzip the archive (≈360 MB) to obtain a folder containing a .img file (~1.7 GB).

2️⃣ Write the image to the SD card

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

3️⃣ Configure the boot partition

After flashing, the SD card shows a single boot partition (≈40 MB). Create two empty files: ssh (no extension, no content) – enables SSH on first boot. wpa_supplicant.conf – add the following (replace with your 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"
}

4️⃣ Assemble and power up

Insert the prepared SD card into the Zero W, connect power via the micro‑USB cable, and wait for the LED to become steady.

Find the device’s IP address on your router (e.g., 192.168.0.104) and SSH into it (default user pi, password raspberry).

3. Optimizing the system

3.1 Change package sources

Replace the default mirrors with a domestic source (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

Then run:

sudo apt-get update
sudo apt-get upgrade

3.2 Set timezone

sudo dpkg-reconfigure tzdata
# choose Asia → Shanghai

3.3 Enable SSH on boot

Method 1 (raspi‑config):

sudo raspi-config
# navigate to Interfacing Options → SSH → Enable

Method 2 (manual): edit /etc/rc.local and add before exit 0:

/etc/init.d/ssh start

4. Installing 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

Visit http://192.168.0.104 in a browser to see the Nginx welcome page.

5. Exposing the device to the internet (ngrok / frp)

Use a tunneling service such as ngrok or frp. The author prefers the ittun build of ngrok for ARM.

Run ngrok in a screen session so it stays alive after logout:

screen -S ngrok
./ngrok tcp 22   # example command

Access the device via the provided public address (e.g., http://zerow.ittun.com/).

6. Final notes

The Zero W can run a small website, serve via Nginx, and be accessed remotely through a tunnel. After a couple of days of operation, memory usage stays around 250 MB, CPU temperature stays between 37‑39 °C, and the device remains stable.

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.

linuxNginxRaspberry PiSSHSystem SetupngrokZero W
Java Backend Technology
Written by

Java Backend Technology

Focus on Java-related technologies: SSM, Spring ecosystem, microservices, MySQL, MyCat, clustering, distributed systems, middleware, Linux, networking, multithreading. Occasionally cover DevOps tools like Jenkins, Nexus, Docker, and ELK. Also share technical insights from time to time, committed to Java full-stack development!

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.