Ubuntu Server on Raspberry Pi delivers a familiar, enterprise-grade Linux environment on affordable hardware. Whether you want to self-host a web application, run a VPN, set up a home media server, or simply learn Linux system administration, Ubuntu Server on Pi gives you a near-identical experience to a cloud VM — but physically in your possession, with no monthly fees. This comprehensive guide covers the complete Raspberry Pi Ubuntu Server setup from flashing the SD card to a secured, production-ready configuration.
Why Choose Ubuntu Server Over Raspberry Pi OS?
Raspberry Pi OS is purpose-built for Pi hardware and excellent for GPIO projects. Ubuntu Server brings different advantages:
- LTS support: Ubuntu 24.04 LTS is supported until 2029, with security updates guaranteed
- ARM64 native packages: The full Ubuntu repository has 60,000+ packages compiled for 64-bit ARM
- Familiar environment: If your production servers run Ubuntu, your Pi lab matches production
- Snap support: Many enterprise tools (Microk8s, LXD, Nextcloud) install via snap in seconds
- Netplan networking: Clean, declarative network configuration instead of dhcpcd
- No desktop overhead: Boots to under 150MB RAM usage, leaving maximum memory for your applications
The main trade-off is that Ubuntu Server has less Pi-specific hardware support out of the box. GPIO libraries, camera stack, and some HATs need extra configuration steps covered in this guide.
Hardware Requirements and What You Need
Before starting, gather these components:
- Raspberry Pi 4 (2GB minimum) or Raspberry Pi 5 (recommended)
- MicroSD card: 32GB minimum, 64GB recommended (Class 10 / A2 rated)
- Reliable power supply: Official 15W (Pi 4) or 27W (Pi 5) USB-C adapter
- Ethernet cable for initial setup (much more reliable than Wi-Fi for first boot)
- Another computer to flash the SD card
Optional but recommended for a server: USB SSD or NVMe HAT (Pi 5 has PCIe). Running Ubuntu Server from an SSD dramatically improves database performance and SD card longevity. A quality SSD lasts far longer than a microSD under continuous write loads like logging and database operations.
Flashing Ubuntu Server to MicroSD or SSD
The easiest method uses the official Raspberry Pi Imager tool:
- Download Raspberry Pi Imager from
raspberrypi.com/softwareand install it on your PC or Mac - Click Choose OS → Other general-purpose OS → Ubuntu → Ubuntu Server 24.04 LTS (64-bit)
- Click the gear icon (advanced options) before flashing — this is critical for headless setup:
- Enable SSH (use password authentication initially)
- Set a username and password
- Configure Wi-Fi SSID and password (optional if using Ethernet)
- Set locale and timezone
- Click Write and wait for flashing and verification to complete
Insert the card, connect Ethernet, and power on the Pi. Wait 2–3 minutes for first boot (Ubuntu expands the filesystem and applies your Imager settings on first run).
First Connection: SSH and Initial Configuration
Find your Pi’s IP address from your router’s admin panel (look for a device named “ubuntu”), then SSH in:
ssh [email protected]
Log in with the password you set in Imager. The system will prompt you to change the password if you used a simple one.
Immediate post-login steps
# Update all packages
sudo apt update && sudo apt upgrade -y
# Install essential tools
sudo apt install -y vim curl wget git htop net-tools unattended-upgrades
# Enable automatic security updates
sudo dpkg-reconfigure --priority=low unattended-upgrades
# Set your timezone
sudo timedatectl set-timezone Asia/Kolkata
# Verify time sync
timedatectl status
Setting a Static IP Address with Netplan
A server needs a fixed IP address so you always know where to find it. Ubuntu uses Netplan for network configuration:
sudo nano /etc/netplan/50-cloud-init.yaml
Replace the contents with (adjust interface name and IP for your network):
network:
version: 2
ethernets:
eth0:
dhcp4: no
addresses:
- 192.168.1.100/24
routes:
- to: default
via: 192.168.1.1
nameservers:
addresses: [8.8.8.8, 1.1.1.1]
wifis:
wlan0:
dhcp4: yes
access-points:
"Your-WiFi-SSID":
password: "your-wifi-password"
sudo netplan apply
Check your interface name first with ip link show — Pi 5 typically shows eth0, but check to be sure.
Security Hardening: SSH Keys, Firewall, and Fail2ban
A server accessible on your home network (and potentially the internet via port forwarding) needs proper security. Apply these steps in order.
SSH Key Authentication
On your local machine, generate a key pair if you don’t have one:
ssh-keygen -t ed25519 -C "pi-server"
ssh-copy-id [email protected]
Then disable password authentication on the server:
sudo nano /etc/ssh/sshd_config
Set these values:
PasswordAuthentication no
PubkeyAuthentication yes
PermitRootLogin no
MaxAuthTries 3
Port 2222 # Optional: change default port
sudo systemctl restart sshd
UFW Firewall
sudo apt install ufw -y
sudo ufw default deny incoming
sudo ufw default allow outgoing
sudo ufw allow 2222/tcp # SSH (use 22 if you kept default)
sudo ufw allow 80/tcp # HTTP
sudo ufw allow 443/tcp # HTTPS
sudo ufw enable
sudo ufw status verbose
Fail2ban
sudo apt install fail2ban -y
sudo cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local
sudo nano /etc/fail2ban/jail.local
Add under [sshd]:
[sshd]
enabled = true
port = 2222
filter = sshd
logpath = /var/log/auth.log
maxretry = 3
bantime = 86400
sudo systemctl enable fail2ban && sudo systemctl start fail2ban
Installing Nginx and Running a Web Server
Nginx on Ubuntu Server gives you a production-grade web server. Install and configure it:
sudo apt install nginx -y
sudo systemctl enable nginx
sudo systemctl start nginx
Test by visiting http://192.168.1.100 — you should see the Ubuntu/Nginx welcome page.
Deploying a simple site
sudo mkdir -p /var/www/myapp/html
sudo chown -R $USER:$USER /var/www/myapp
echo '<h1>Hello from Pi!</h1>' > /var/www/myapp/html/index.html
sudo nano /etc/nginx/sites-available/myapp
server {
listen 80;
server_name 192.168.1.100;
root /var/www/myapp/html;
index index.html;
location / { try_files $uri $uri/ =404; }
}
sudo ln -s /etc/nginx/sites-available/myapp /etc/nginx/sites-enabled/
sudo nginx -t && sudo systemctl reload nginx
Adding HTTPS with Let’s Encrypt (for public domains)
If your Pi is accessible publicly with a domain name:
sudo apt install certbot python3-certbot-nginx -y
sudo certbot --nginx -d yourdomain.com
Certbot automatically modifies your Nginx config and sets up auto-renewal via systemd timer.
Running Docker and Containers on Ubuntu Server Pi
Docker makes deploying complex applications (Nextcloud, Gitea, Jellyfin) trivial. Install the official Docker Engine:
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
sudo usermod -aG docker ubuntu
newgrp docker
Verify:
docker run hello-world
Docker Compose for multi-container apps
sudo apt install docker-compose-plugin -y
docker compose version
Example: Run Nextcloud with Docker Compose (a complete cloud storage server in 20 lines of YAML). The ARM64 images for Nextcloud, PostgreSQL, and virtually every major service are available on Docker Hub and work natively on Pi 5.
Using GPIO on Ubuntu Server (Python + lgpio)
Ubuntu Server supports GPIO, but uses lgpio instead of RPi.GPIO:
sudo apt install python3-lgpio -y
pip3 install lgpio
Sample blink script:
import lgpio
import time
chip = lgpio.gpiochip_open(0)
lgpio.gpio_claim_output(chip, 17)
try:
while True:
lgpio.gpio_write(chip, 17, 1)
time.sleep(0.5)
lgpio.gpio_write(chip, 17, 0)
time.sleep(0.5)
except KeyboardInterrupt:
lgpio.gpiochip_close(chip)
Frequently Asked Questions
Does Ubuntu Server support Raspberry Pi’s camera?
Yes, but configuration differs from Raspberry Pi OS. Install libcamera-tools and python3-libcamera. The camera stack works via libcamera on Ubuntu 22.04+ for Pi. The legacy camera stack (raspistill, raspivid) is not available on Ubuntu — use libcamera-still instead.
How much faster is a Pi 5 compared to Pi 4 for server workloads?
The Pi 5’s Cortex-A76 cores are 2–3× faster than the Pi 4’s Cortex-A72 for single-threaded workloads like database queries and PHP processing. For multi-threaded tasks like video transcoding or compiling, the improvement is similar. The Pi 5 also has 3× the memory bandwidth, which helps database-heavy applications significantly.
Can I run Ubuntu Server from USB or NVMe instead of SD card?
Yes, and it is strongly recommended for server use. Flash Ubuntu to a USB SSD using Raspberry Pi Imager, then use raspi-config to set USB boot order, or configure EEPROM boot order. Pi 5 supports NVMe via the PCIe connector on a HAT+ board — this gives desktop-class storage performance (2000+ MB/s reads).
Is Ubuntu Server on Raspberry Pi suitable for production web hosting?
For low-traffic personal or small business sites (under 10,000 visitors/day), a Pi 5 with Ubuntu Server, Nginx, and a fast SSD is genuinely production-capable. It is not a replacement for cloud hosting under heavy load, but many makers and small businesses run their sites from home Pi servers behind Cloudflare.
How do I keep Ubuntu Server updated automatically?
The unattended-upgrades package handles security patches automatically. For full system upgrades, run sudo apt update && sudo apt upgrade manually once a week. For major Ubuntu version upgrades (e.g., 22.04 → 24.04), use sudo do-release-upgrade after the new LTS release is available.
—
Start building your Pi server today. Find Raspberry Pi 5 boards, accessories, and storage solutions at Zbotic.in — genuine components with fast delivery across India and technical support when you need it.
Add comment