Fundamentals 11 min read

How to Set Up Raspberry Pi Zero W: Install the OS, Enable SSH, and Deploy Nginx with Ngrok

This tutorial walks you through understanding what a Raspberry Pi Zero W is, preparing the required hardware and software, flashing the Raspbian image, enabling SSH and Wi‑Fi, installing Nginx, and exposing the device to the internet using Ngrok, all with detailed step‑by‑step instructions and code snippets.

Java Architect Essentials
Java Architect Essentials
Java Architect Essentials
How to Set Up Raspberry Pi Zero W: Install the OS, Enable SSH, and Deploy Nginx with Ngrok

The article begins with a brief introduction to the Raspberry Pi, describing it as a credit‑card‑sized Linux‑based computer that, despite its small size, offers a full set of video, audio, and GPIO capabilities.

It then explains the author’s motivation for choosing the low‑cost Raspberry Pi Zero W (about 100 CNY) and lists its main specifications, such as a 1 GHz BCM2835 CPU, 512 MB RAM, Wi‑Fi/Bluetooth chip, micro‑USB power and OTG ports, mini‑HDMI, CSI camera connector, 40‑pin GPIO header, and dimensions of 65 mm × 30 mm.

Preparation : The required items are a 16 GB or 32 GB micro‑SD card, a standard USB‑type‑A cable, a formatting tool (e.g., SDFormatter), the Win32DiskImager utility, and the official Raspbian Stretch Lite image.

Step 1 – Download the OS image : Download the zip file, extract it to obtain a .img file (≈1.7 GB).

Step 2 – Write the image to the SD card using Win32DiskImager: select the .img , choose the SD card device, and click “Write”.

Step 3 – Enable SSH : After flashing, open the boot partition and create an empty file named ssh (no extension).

Step 4 – Configure Wi‑Fi : In the same boot partition, create a file wpa_supplicant.conf with the following content:

country=CN
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
ssid="your_wifi_name"
psk="your_wifi_password"
}

Step 5 – Boot the device : Insert the SD card into the Zero W, power it via the micro‑USB cable, and wait for the LED to become steady. Find the device’s IP address from the router.

Step 6 – SSH into the Pi : Use an SSH client (e.g., PuTTY) with username pi and password raspberry .

Step 7 – Optimize the system : Replace the default apt sources with a domestic mirror (e.g., USTC) by editing /etc/apt/sources.list and /etc/apt/sources.list.d/raspi.list , then run sudo apt-get update && sudo apt-get upgrade . Set the timezone to Asia/Shanghai with sudo dpkg-reconfigure tzdata . Enable SSH on boot via sudo raspi-config or by adding /etc/init.d/ssh start before exit 0 in /etc/rc.local .

Step 8 – 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:// pi_ip in a browser to verify the web server.

Step 9 – Expose the service to the internet using a tunneling tool such as Ngrok (or alternatives like ittun, sunny, natapp). The author uses the ngrok_arm binary, runs it inside a screen session, and points it to the Pi’s HTTP port.

The article concludes with a brief note that the Zero W can run additional services, shows current resource usage (≈250 MB free RAM, CPU temperature 37‑39 °C), and encourages readers to explore more Raspberry Pi projects.

LinuxNginxIoTRaspberry PiSSHNgrokZero W
Java Architect Essentials
Written by

Java Architect Essentials

Committed to sharing quality articles and tutorials to help Java programmers progress from junior to mid-level to senior architect. We curate high-quality learning resources, interview questions, videos, and projects from across the internet to help you systematically improve your Java architecture skills. Follow and reply '1024' to get Java programming resources. Learn together, grow together.

0 followers
Reader feedback

How this landed with the community

login 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.