Raspberry Pi Environment Construction Guide

 



1. Hardware Preparation

  • Raspberry Pi ModelPi 4 (recommended), Pi 5 (newest), or Pi Zero (compact projects)

  • MicroSD Card → 16GB+ (Class 10 or UHS-I), or SSD for better speed

  • Power Supply → Official Pi adapter (5V 3A for Pi 4, 5V 5A for Pi 5)

  • Cables & Peripherals:

    • HDMI cable + monitor (optional, for first setup)

    • USB keyboard/mouse (optional, if not headless)

    • Ethernet cable (preferred) or Wi-Fi

  • (Optional) Case + heatsink/fan for cooling


2. Install the Operating System

  1. Download Raspberry Pi Imager:
    https://www.raspberrypi.com/software

  2. Flash OS to microSD:

    • Choose OS:

      • Raspberry Pi OS Lite → headless, server projects

      • Raspberry Pi OS Desktop → GUI for beginners

    • Enable SSH, set Wi-Fi SSID/PW, and hostname in advanced options.

  3. Insert SD card → power up Pi.


3. First Boot & Basic Setup

Login (default):

Username: pi Password: raspberry

Then:

sudo raspi-config
  • Change password

  • Set timezone & locale

  • Enable SSH / I2C / SPI / Camera (if needed)

  • Reboot

Update system:

sudo apt update && sudo apt upgrade -y

4. Networking Setup

  • Static IP (recommended for servers):

sudo nano /etc/dhcpcd.conf

Add:

interface eth0 static ip_address=192.168.1.100/24 static routers=192.168.1.1 static domain_name_servers=8.8.8.8 8.8.4.4
  • Reboot:

sudo reboot

Now your Pi has a fixed IP.


5. Essential Tools Installation

sudo apt install git curl wget htop unzip build-essential -y
  • Python tools:

sudo apt install python3-pip python3-venv -y
  • Node.js (for web/IoT projects):

curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash - sudo apt install -y nodejs
  • Docker (for containerized apps):

curl -sSL https://get.docker.com | sh sudo usermod -aG docker pi

6. Development Environment

  • C/C++: Already available via gcc / make.

  • Python IDEs:

    • Thonny (GUI) → sudo apt install thonny -y

    • VS Code (remote SSH) → install on your PC, connect to Pi.

  • IoT Libraries:

    • GPIO: pip install RPi.GPIO

    • I2C/SPI: sudo apt install python3-smbus i2c-tools


7. Storage & Backup

  • Mount external drive:

sudo mkdir /mnt/storage sudo mount /dev/sda1 /mnt/storage
  • Add to /etc/fstab for auto-mount.

  • Backup system image with rpi-clone or Raspberry Pi Imager.


8. Remote Access & Monitoring

  • SSH (terminal access): ssh pi@192.168.1.100

  • VNC (remote desktop):

    sudo apt install realvnc-vnc-server realvnc-vnc-viewer -y sudo raspi-config # Enable VNC
  • Web Dashboard (Cockpit):

    sudo apt install cockpit -y

9. Security Hardening

  • Change default password

  • Create new user, disable root login

  • Setup UFW firewall:

    sudo apt install ufw -y sudo ufw allow ssh sudo ufw enable
  • Enable fail2ban to block brute force attacks


10. Project-Specific Extensions

  • NAS/Storage Server → Install OpenMediaVault

  • Media Center → Install Kodi or Plex

  • IoT Gateway → Install Node-RED (sudo apt install nodered)

  • Web Server → Nginx/Apache + MySQL + PHP

  • Home Automation → Home Assistant (docker run homeassistant)


 By following these steps, your Raspberry Pi will be ready as a multi-purpose development and server environment.

评论

此博客中的热门博文

Detailed Explanation of STM32 HAL Library Clock System

How to remove write protection of STM32 chip?

The automatic white balance algorithm of Raspberry Pi