Prepare a Linux Web Server
July 16, 2026 ยท View on GitHub
This chapter uses a generic Debian- or Ubuntu-based server and Nginx as an example. Equivalent web server software can be used if it provides the same HTTP, TLS, logging, and virtual-host capabilities.
Server Requirements
- A public IPv4 address, IPv6 address, or both
- Administrative access through a non-root account with
sudo - Inbound TCP ports 80 and 443 permitted by network and host firewalls
- Security updates enabled or applied regularly
- A backup and recovery plan
Do not publish a server before confirming who is responsible for updates, monitoring, and incident response.
Update the System
sudo apt update
sudo apt upgrade
Review package changes before confirming on a production server.
Install Nginx
sudo apt install nginx
Verify the service:
systemctl status nginx --no-pager
sudo ss -lntp
Nginx should listen on port 80. Do not expose unrelated administration ports to the public internet.
Create a Site Directory
sudo mkdir -p /var/www/example.dpdns.org
sudo chown -R "$USER":"$USER" /var/www/example.dpdns.org
Copy the site files into that directory using a deployment method that preserves expected ownership and permissions.
Configure a Virtual Host
Create /etc/nginx/sites-available/example.dpdns.org:
server {
listen 80;
listen [::]:80;
server_name example.dpdns.org www.example.dpdns.org;
root /var/www/example.dpdns.org;
index index.html;
location / {
try_files $uri $uri/ =404;
}
access_log /var/log/nginx/example.dpdns.org.access.log;
error_log /var/log/nginx/example.dpdns.org.error.log;
}
Enable it:
sudo ln -s /etc/nginx/sites-available/example.dpdns.org /etc/nginx/sites-enabled/example.dpdns.org
sudo nginx -t
sudo systemctl reload nginx
The configuration test must succeed before reloading.
Test Before DNS Changes
From a machine that can reach the server, replace the example IP:
curl -I -H 'Host: example.dpdns.org' http://192.0.2.10
This tests the intended virtual host without waiting for DNS.
Firewall Check
Use the firewall system already chosen for the server. Permit only required inbound services. At minimum, website traffic requires TCP 80 and 443; administration access should be restricted as tightly as practical.
Continue to Deploy and Connect the Domain.