Debian Server Installation
Introduction
Debian is one of the most stable and secure Linux distributions available, making it an excellent choice for server deployments. This guide walks you through the process of installing Debian Server on your hardware or virtual machine. We'll cover everything from downloading the installation media to completing the initial system configuration, ensuring you have a solid foundation for building and managing your server.
Prerequisites
Before we begin, make sure you have:
- A computer or virtual machine with at least:
- 1 GHz CPU
- 1 GB RAM (2 GB recommended)
- 10 GB free disk space
- Access to the internet for downloading the installation media
- A USB drive (2 GB or larger) if installing on physical hardware
- Basic knowledge of computer hardware and networking concepts
Step 1: Download Debian Server Installation Media
The first step is to download the Debian installation image from the official website.
- Visit the Debian downloads page
- Choose the stable version of Debian (currently Debian 12 "Bookworm")
- Select the "netinst" (network installer) image for your architecture (most commonly amd64 for 64-bit systems)
The netinst image is a minimal installation image that downloads necessary packages from the internet during installation, ensuring you get the most up-to-date packages.
Step 2: Create Installation Media
For Physical Hardware
If you're installing on physical hardware, you'll need to create a bootable USB drive:
# On Linux, use the dd command (replace /dev/sdX with your USB drive)
sudo dd if=debian-12.0.0-amd64-netinst.iso of=/dev/sdX bs=4M status=progress
# On Windows, use tools like Rufus or Balena Etcher
For Virtual Machines
If you're using a virtual machine:
- Create a new virtual machine in your hypervisor (VirtualBox, VMware, etc.)
- Configure it with the recommended system resources
- Attach the downloaded ISO file to the virtual machine's optical drive
Step 3: Boot from Installation Media
- Insert your USB drive into the computer or start your virtual machine
- Boot from the installation media (you may need to modify boot order in BIOS/UEFI)
- At the Debian installer boot menu, select "Install" (not "Graphical install" for the server version)
Step 4: Basic Configuration
Follow the on-screen prompts to configure basic settings:
-
Select Language, Location, and Keyboard Layout
- Choose based on your preferences and region
-
Configure Network
- Set up a hostname for your server (e.g.,
debian-server
) - Configure a domain name if needed (e.g.,
local
for home use)
- Set up a hostname for your server (e.g.,
-
Set Up Users and Passwords
- Create a root password (make it strong!)
- Create a regular user account
- Set a password for the user account
Step 5: Disk Partitioning
The installer will guide you through partitioning your disk:
-
Select "Guided - use entire disk" for a simple setup
-
Choose the target disk for installation
-
Select a partitioning scheme:
- "All files in one partition" is simplest for beginners
- "Separate /home partition" provides better separation of system and user data
- "Separate /home, /var, and /tmp partitions" offers maximum flexibility
-
Review the proposed changes and confirm to write changes to disk
For a basic server, a partition layout might look like:
/ - 8GB (root filesystem)
/home - 10GB (user data)
swap - 2GB (virtual memory)
Step 6: Package Selection
The installer will ask which software to install:
- When prompted for a mirror, select a server close to your location
- Configure the package manager proxy if needed (usually blank is fine)
- Choose whether to participate in the package usage survey (optional)
- At the software selection screen, typically select:
- SSH server
- Standard system utilities
Deselect the Desktop environment for a minimal server installation.
Here's what the software selection screen might look like:
[ ] Debian desktop environment
[ ] GNOME
[ ] Xfce
[ ] KDE Plasma
[ ] Cinnamon
[ ] MATE
[ ] LXDE
[ ] LXQt
[*] SSH server
[*] Standard system utilities
[ ] Print server
[ ] Web server
[ ] Database server
Step 7: Install GRUB Boot Loader
- When prompted, install GRUB boot loader to the master boot record (MBR)
- Select the disk where GRUB should be installed (usually the same disk as the system)
Step 8: Complete Installation
- The system will finalize the installation and prompt you to remove the installation media
- Reboot the system
Congratulations! You now have a basic Debian server installed.
Step 9: First Boot and Initial Configuration
After rebooting, log in with the user account you created during installation.
Update Your System
It's good practice to update your system immediately after installation:
# Switch to root user
su -
# Update package lists
apt update
# Upgrade all packages
apt upgrade
# Alternatively, use sudo if configured
sudo apt update && sudo apt upgrade
Configure SSH for Remote Access
If you plan to manage your server remotely, ensure SSH is properly configured:
# Check SSH service status
systemctl status ssh
# If needed, start and enable SSH at boot
systemctl start ssh
systemctl enable ssh
To enhance security, consider editing the SSH configuration:
# Edit SSH config file
sudo nano /etc/ssh/sshd_config
# Make these security changes:
# - Change default port
# - Disable root login
# - Use public key authentication
# - Limit user access
# Restart SSH after changes
sudo systemctl restart ssh
Configure Firewall
Set up a basic firewall using UFW (Uncomplicated Firewall):
# Install UFW if not already installed
sudo apt install ufw
# Allow SSH connections (adjust port if you changed it)
sudo ufw allow 22/tcp
# Enable the firewall
sudo ufw enable
# Check status
sudo ufw status
Common Issues and Troubleshooting
Network Configuration Problems
If you encounter network issues:
# Check network interface status
ip a
# Test connectivity
ping -c 4 1.1.1.1
# Check DNS resolution
nslookup debian.org
# Restart networking
sudo systemctl restart networking
Boot Problems
If your system fails to boot:
- Boot from installation media and select "Rescue mode"
- Follow prompts to mount your system
- Check and repair GRUB if needed:
# Update GRUB
update-grub
# Reinstall GRUB if necessary
grub-install /dev/sda
Server Administration Basics
Here are some basic commands to help you manage your Debian server:
# Check system information
uname -a
lsb_release -a
# Monitor system resources
top
htop # may need to install: sudo apt install htop
# View disk usage
df -h
du -sh /var/log
# View system logs
less /var/log/syslog
# Manage services
sudo systemctl status service-name
sudo systemctl start service-name
sudo systemctl enable service-name
Security Best Practices
To keep your Debian server secure:
-
Keep the system updated
bashsudo apt update && sudo apt upgrade
-
Install security updates automatically
bashsudo apt install unattended-upgrades
sudo dpkg-reconfigure unattended-upgrades -
Use strong passwords and consider public key authentication for SSH
-
Limit user privileges - use sudo instead of root
-
Install and configure fail2ban to protect against brute force attacks
bashsudo apt install fail2ban
sudo cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local
sudo nano /etc/fail2ban/jail.local
sudo systemctl restart fail2ban
Next Steps
After setting up your Debian server, you might want to:
- Install and configure web services (Apache, Nginx)
- Set up databases (MySQL, PostgreSQL)
- Configure email services (Postfix, Dovecot)
- Set up monitoring tools (Prometheus, Grafana)
- Implement regular backup solutions
Summary
In this guide, we've covered:
- Downloading Debian Server installation media
- Creating bootable installation media
- Installing Debian with a server-oriented configuration
- Performing initial system setup and security hardening
- Basic server administration commands and concepts
Debian's stability and security make it an excellent choice for servers. By following this guide, you've established a solid foundation for hosting various services and applications.
Additional Resources
Exercises for Practice
- Install and configure a web server (Apache or Nginx) on your Debian server
- Set up a firewall with specific rules for your services
- Create a backup script that archives important configuration files
- Configure automatic updates with email notifications
- Install and set up a monitoring system to track server performance
Remember that server administration is a continuous learning process. Start with small projects and gradually build your skills and confidence.
If you spot any mistakes on this website, please let me know at [email protected]. I’d greatly appreciate your feedback! :)