You just got a brand-new physical server (or VM) and you want it to go from bare metal to a production-ready Linux server within one day — with security, backup and operations all properly set up. This article is the blueprint for that.
We’ll walk through a “one-day go-live workflow”: from choosing a distro, disk layout, network and SSH baseline security, account and permission design, systemd service management, firewall and Fail2Ban, all the way to a final go-live checklist. You can treat this as your standard SOP whenever a new Linux server is provisioned.
1. Pre-deployment Planning: Don’t Step on Landmines before Installation
1.1 Clarify the Purpose of This Server
- Use case: Web server? API? Database? CI/CD runner? File server?
- Expected load: Concurrent connections, QPS, whether there is heavy I/O (logs, DB).
- Access scope: Internal only? Internet-facing? Through VPN?
- Lifetime & scalability: Short-term PoC vs long-term production? Need to scale storage or add nodes later?
These decisions will affect whether you need RAID/ZFS, a dedicated proxy, or even clustering/HA.
1.2 Choose a Linux Distribution and Installation Method
Common server-oriented distros:
- Debian / Ubuntu Server: Modern packages, abundant documentation, great for web & DevOps.
- Rocky / Alma / RHEL family: Enterprise favorite with long support cycles.
- openSUSE / SLES: Yast-based management, popular in certain enterprise environments.
Installation methods:
- Physical server: Boot from USB / IPMI virtual media.
- Virtual machine: Create a VM in Proxmox / VMware / Hyper-V and mount the ISO.
- Cloud: Use provider images to skip manual installation, but you still must apply security baselines.
1.3 Disk Layout and Filesystem Design
Think about this before you hit “Next, next, finish” in the installer:
- Separate system and data:
split
/from/dataor/var/libto prevent a single directory filling up and taking down the whole system. - LVM or ZFS: Both are great for future resizing and snapshots.
- RAID: For important services, consider RAID1/RAID10 with a hardware controller or ZFS/MD RAID.
# Example: inspect your block devices and partitions
lsblk -f
# Check filesystem usage
df -h
2. OS Installation and Basic Post-Install Setup
2.1 Recommended Installer Choices
- Minimal / Server installation: No GUI needed, smaller attack surface.
- Enable SSH server: Select OpenSSH server or equivalent during install.
- Partitioning / filesystem: Follow your LVM/ZFS/ext4/xfs plan.
2.2 First Things First: Updates and Essential Tools
# Debian / Ubuntu
sudo apt update && sudo apt -y upgrade
sudo apt install -y vim htop curl wget git net-tools
# RHEL / Rocky / Alma
sudo dnf update -y
sudo dnf install -y vim htop curl wget git net-tools
2.3 Hostname, Timezone and NTP
# Set hostname
sudo hostnamectl set-hostname web01-prod
# Check current settings
hostnamectl
# Set timezone (example: Taipei)
sudo timedatectl set-timezone Asia/Taipei
# Enable NTP time sync
sudo timedatectl set-ntp true
timedatectl status
Consistent timezone and accurate time are critical for reading logs and troubleshooting issues.
3. Networking and SSH Baseline Security
3.1 Static IP, Gateway and DNS
Example with Netplan on Ubuntu 20.04+:
sudo vim /etc/netplan/01-netcfg.yaml
network:
version: 2
renderer: networkd
ethernets:
eno1:
dhcp4: no
addresses:
- 192.168.10.50/24
gateway4: 192.168.10.1
nameservers:
addresses: [8.8.8.8, 1.1.1.1]
# Apply configuration
sudo netplan apply
3.2 SSH Hardening: Disable Root Password Login and Enable Keys
- Create a normal admin account first (next section).
- Generate keys on your workstation:
ssh-keygen -t ed25519 - Upload the public key:
ssh-copy-id user@server
# Edit SSH config
sudo vim /etc/ssh/sshd_config
# Recommended baseline
PermitRootLogin no
PasswordAuthentication no
PubkeyAuthentication yes
X11Forwarding no
AllowUsers youradminuser
# Reload SSH daemon
sudo systemctl reload sshd
Before turning off PasswordAuthentication,
confirm that key-based login works to avoid locking yourself out.
4. Accounts, Groups, Permissions and ACL
4.1 Create an Admin User with sudo Privileges
# Create user with home directory
sudo useradd -m -s /bin/bash admin
# Set password (can later disable password login and use keys only)
sudo passwd admin
# Add to sudo group (Ubuntu)
sudo usermod -aG sudo admin
# RHEL / Rocky often uses 'wheel'
sudo usermod -aG wheel admin
4.2 Basic File Permissions
# Show file permissions
ls -l
# Change owner
sudo chown user:group filename
# Change permissions
sudo chmod 640 filename
sudo chmod 750 directory
4.3 Advanced Control with ACL
# Grant extra user rwx access via ACL
sudo setfacl -m u:devuser:rwx /srv/app
# Check ACL
getfacl /srv/app
ACL is perfect for scenarios like: “this directory is owned by a group, but we want one extra user to have read/write access”.
5. systemd: The Core of Services and Scheduling
5.1 Common systemctl Commands
# Service status
sudo systemctl status nginx
# Start / stop / restart
sudo systemctl start nginx
sudo systemctl stop nginx
sudo systemctl restart nginx
# Enable / disable at boot
sudo systemctl enable nginx
sudo systemctl disable nginx
# Check boot-time performance
systemd-analyze blame
5.2 Creating a Custom Service Unit (Example Web App)
sudo vim /etc/systemd/system/myapp.service
[Unit]
Description=My Example Web Application
After=network.target
[Service]
User=www-data
Group=www-data
WorkingDirectory=/srv/myapp
ExecStart=/usr/bin/python3 app.py
Restart=on-failure
[Install]
WantedBy=multi-user.target
# Reload and enable service
sudo systemctl daemon-reload
sudo systemctl enable --now myapp.service
5.3 systemd Timer Instead of Crontab
# backup.service
sudo vim /etc/systemd/system/backup.service
[Unit]
Description=Daily backup job
[Service]
Type=oneshot
ExecStart=/usr/local/sbin/daily-backup.sh
# backup.timer
sudo vim /etc/systemd/system/backup.timer
[Unit]
Description=Run backup.service daily at 02:00
[Timer]
OnCalendar=*-*-* 02:00:00
Persistent=true
[Install]
WantedBy=timers.target
# Enable timer
sudo systemctl daemon-reload
sudo systemctl enable --now backup.timer
Timers give you logs and easy status via systemctl status,
which is often better than traditional cron from an operations standpoint.
6. Logging: journalctl and logrotate
6.1 journalctl Basics
# Logs from current boot
journalctl -b
# Follow logs for a specific service
journalctl -u nginx -f
# Restrict to a time range
journalctl --since "2025-11-15 00:00" --until "2025-11-15 23:59"
6.2 Controlling Log Growth with logrotate
# Example nginx logrotate config
cat /etc/logrotate.d/nginx
/var/log/nginx/*.log {
daily
missingok
rotate 14
compress
delaycompress
notifempty
create 0640 www-data adm
sharedscripts
postrotate
[ -s /run/nginx.pid ] && kill -USR1 `cat /run/nginx.pid`
endscript
}
For custom applications, write your own logrotate config to prevent logs from filling up the disk.
7. Firewall and Intrusion Protection (iptables / nftables / Fail2Ban)
7.1 Choosing a Firewall Frontend
- ufw (Ubuntu): Simple and human-friendly.
- firewalld (RHEL family): Zone-based, tightly integrated.
- Raw iptables / nftables: Maximum flexibility, but you must manage rules yourself.
# ufw example: only allow 22, 80, 443
sudo ufw default deny incoming
sudo ufw default allow outgoing
sudo ufw allow 22/tcp
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw enable
7.2 Protect Against Brute Force with Fail2Ban
# Install Fail2Ban
sudo apt install -y fail2ban
# Create local config
sudo cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local
sudo vim /etc/fail2ban/jail.local
[sshd]
enabled = true
port = ssh
filter = sshd
logpath = /var/log/auth.log
maxretry = 5
findtime = 600
bantime = 3600
# Enable
sudo systemctl enable --now fail2ban
fail2ban-client status sshd
You can also create jails for Nginx, Postfix and other services to build a broader protection layer.
8. Exposing Services: Nginx Reverse Proxy + HTTPS
8.1 Install Nginx
# Debian / Ubuntu
sudo apt install -y nginx
# RHEL / Rocky / Alma
sudo dnf install -y nginx
sudo systemctl enable --now nginx
8.2 Virtual Host and Reverse Proxy
sudo vim /etc/nginx/sites-available/myapp.conf
server {
listen 80;
server_name example.com;
access_log /var/log/nginx/myapp_access.log;
error_log /var/log/nginx/myapp_error.log;
location / {
proxy_pass http://127.0.0.1:5000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
# Enable site (Debian / Ubuntu)
sudo ln -s /etc/nginx/sites-available/myapp.conf /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginx
8.3 Let’s Encrypt Free TLS Certificates
# Install certbot and Nginx plugin (adjust per distro)
sudo apt install -y certbot python3-certbot-nginx
# Request and configure certificate automatically
sudo certbot --nginx -d example.com
# Check renewal timer
systemctl status certbot.timer
With HTTPS enabled, plus firewall and Fail2Ban in place, your server now has a solid baseline security posture.
9. Proxy and Update Strategy (Optional but Common in Enterprises)
In many enterprise environments, outbound traffic must go through a proxy (e.g., Squid) for package updates or internet access.
- On the proxy server, restrict destination hosts to official OS repositories and known sites.
- On application servers, configure
HTTP_PROXY/HTTPS_PROXYenvironment variables or apt/dnf proxy settings. - Use log analysis tools (like GoAccess) to monitor proxy traffic.
If you maintain your own proxy tutorial, link it here to build a complete “secure go-live path”.
10. Backup and Restore Drills: No Backup, No Go-Live
10.1 What to Back Up?
- System configuration:
/etc, systemd units, Nginx configs, Fail2Ban, firewall rules. - Applications and data:
/srv,/var/www, databases. - Accounts and permissions:
/home, ACL configuration.
10.2 Simple File Backup with rsync
# Backup /etc to a backup server
rsync -avz /etc backup@backup-server:/backup/web01/etc/
# Backup web files
rsync -avz /var/www/ backup@backup-server:/backup/web01/www/
10.3 Snapshots and Image-level Backups
- On Proxmox, use snapshot + backup for VM-level protection.
- With ZFS, consider
zfs snapshot+zfs send/receivefor advanced replication.
10.4 Always Perform Restore Drills
Backups without restore tests are just self-comfort. At minimum, you should:
- Bring up a test environment from your backup and verify the service.
- Document every step into an SOP or runbook.
11. 20-Item Pre-Go-Live Checklist
- Hostname and timezone are correct;
timedatectlshows healthy NTP status. - System is fully updated with no critical security patches pending.
- Accounts/groups are planned; no unnecessary default accounts remain.
- Root SSH login is disabled.
- All admin accounts use SSH keys for login.
- Unused SSH features (X11Forwarding, password login, etc.) are disabled.
- Firewall is active, only required ports are open (22, 80, 443, etc.).
- Fail2Ban or equivalent is enabled and successfully bans test IPs.
- Nginx/Web server configs pass validation (e.g.,
nginx -t). - HTTPS certificates are valid; browsers show no security warnings.
- All services are managed by systemd with proper
Restart=policies. - Custom services/timers are enabled and verified after reboot.
- logrotate is configured for high-volume log paths.
- Disk usage (
df -h) is within safe thresholds, no partition above ~80%. - Critical configs and data are backed up to another host or remote location.
- Backup jobs have run at least once and have been manually verified.
- Basic load/stress testing has been performed (ab, wrk, etc.) and resource usage is understood.
- Monitoring/alerting is in place (Zabbix, Prometheus, or even simple shell checks).
- Documentation exists: IPs, accounts, ports, service versions, backup locations.
- A rollback plan is prepared: previous VM images, old snapshots, and a clear go/no-go procedure.
12. Next Steps and Advanced Topics
Once you’ve finished everything in this blueprint, you essentially have a Linux server that you can proudly call production-ready. From here, you can explore:
- Virtualization and clustering: Proxmox / KVM multi-node setups and HA scenarios.
- Automation & IaC: Use Ansible / Terraform to turn this entire workflow into code.
- Advanced security: SELinux / AppArmor, endpoint protection, WAF, Zero Trust concepts.
- Observability: Prometheus + Grafana, ELK / OpenSearch for logs and metrics.
If you want this to become a team-wide standard, you can adapt this article into an internal “Linux New Server Go-Live SOP”, then pair it with automation so that every new server can go from bare metal to a stable, secure production host within a single day.
ๆฒๆ็่จ:
ๅผต่ฒผ็่จ