🛠 Héberger un serveur web léger sur 256 MB de RAM

Raspberry Pi Model B (Rev 1, 2012) — Board Sheet · avance · Schéma : IMG-model-b-rev1-avance-3-modelb1-serveur-web-leger.svg — Model B Rev 1 en serveur, câble Ethernet vers le routeur, navigateur d'un ordinateur affichant une page servie par lighttpd, jauge de RAM 256 MB mise en avant

Objectives

Transform the Model B Rev 1 into a small permanent web server, taking into account its two bottlenecks: 256 MB of RAM shared between CPU/GPU and 10/100 Ethernet behind the LAN9512 chip. Apache is excluded; we choose lighttpd (or busybox httpd) with a few static pages and a status endpoint. You will learn how to size gpu_mem, serve via systemd, and measure the actual throughput.

Hardware

Complete code

# 1) Liberer de la RAM pour le CPU : /boot/config.txt -> gpu_mem=16
#    (pas d'usage GPU prevu), puis sudo reboot

# 2) Installer et demarrer lighttpd
sudo apt install -y lighttpd
sudo systemctl enable --now lighttpd

# 3) Page de statut dynamique (CGI shell minimal)
sudo mkdir -p /srv/www && echo 'server.document-root = "/srv/www"' | sudo tee /etc/lighttpd/conf-enabled/99-site.conf
printf '#!/bin/sh\necho "Content-Type: text/plain"\necho\nvcgencmd measure_temp\nvcgencmd measure_clock arm\nfree -m | head -2\n' | sudo tee /srv/www/status.cgi
sudo chmod +x /srv/www/status.cgi
echo 'cgi.assign = ( ".cgi" => "" )' | sudo tee -a /etc/lighttpd/conf-enabled/99-site.conf
sudo systemctl restart lighttpd

# 4) Tester depuis un autre poste
curl http://192.168.1.50/status.cgi

# 5) Debit reel (test depuis le PC, attendez-vous a ~5-9 MB/s max)
scp page-test-10Mo.bin pi@192.168.1.50:/tmp/

Expected verification

curl http://<ip-du-pi>/status.cgi returns the temperature, ARM clock, and free memory. free -m shows 150-200 MB available with lighttpd alone. The server remains stable in permanent service; transfer throughput caps at a few MB/s, consistent with 100 Mbps Ethernet shared with USB.

Common errors

Other tutorials for this board

Code examples for this board

← Back to the board 🛠 All tutorials