🛠 Héberger un serveur web léger
Objectives
Install a minimal web server (lighttpd) on the 512 MB of the Model B Rev 2, serve a static page on port 80 via 10/100 Ethernet, and set realistic expectations due to the single USB bus shared with the LAN9512.
Hardware
- Raspberry Pi Model B Rev 2, Raspbian legacy 32-bit, Ethernet connection (no WiFi on this board)
- SSH access (tutorial modelb2-ethernet-ssh) or screen/keyboard
- Healthy SD card: a web server logging to a worn-out SD card will corrupt it
Complete code
sudo apt update && sudo apt install -y lighttpd
sudo lighty-enable-mod fastcgi 2>/dev/null || true
sudo service lighttpd force-reload
# Page de test
sudo mkdir -p /var/www/html
echo "<h1>Bonjour depuis le Model B Rev 2</h1>" | sudo tee /var/www/html/index.html
# Ecoute et debit attendu (10/100 partage le bus USB 480 Mbps avec les ports USB)
sudo netstat -tlnp | grep :80
curl -s http://localhost/ | head -2
# Depuis un poste du reseau:
curl -s http://192.168.1.50/
Expected verification
curl http://localhost/ returns the page title; from another machine on the network, the same page displays in a browser; netstat shows lighttpd listening on port 80. The actual throughput caps well below 100 Mbps when a USB device is active, which is normal for this architecture.
Common errors
- Publishing directly to the Internet without due consideration: exposing a home port 80 requires a deliberate choice (NAT, firewall); prefer local usage.
- Using Apache instead of lighttpd: on 512 MB and ARMv6, Apache wastes available RAM.
- Logging to the SD card, which wears it out: limit verbosity or redirect to tmpfs.
- Forgetting to restart the service after configuration changes: use
force-reload, not juststart.
Other tutorials for this board
Code examples for this board
led_blink.pyPythonbutton_led.pyPythonservo_sweep.pyPythondht_temp.pyPythonoled_i2c.pyPythonmcp3008_read.pyPython