Basic Server Setup for a Small Website: A Practical Checklist
Most small websites never need a server of their own. Shared hosting or a managed platform handles the hard parts for you. But when a site outgrows that, or a client wants more control, you end up with a VPS and a blank command line. This guide covers the basic setup for a small website server: what to install, what to lock down, and the routine that keeps it running. It is written for designers and developers who manage a few sites, not for full-time system administrators.
If you are still deciding whether you need a server at all, start with How to Choose Web Hosting: What to Check Before You Buy.
Managed or unmanaged?
Before you buy a VPS, be honest about who will look after it. An unmanaged server means you are responsible for updates, security, backups and fixing it at 2 a.m. A managed VPS or a platform like a managed WordPress host costs more, but someone else does that work.
A good rule: if nobody on the team is comfortable with Linux and SSH, choose managed. A neglected server is a bigger risk than a slightly higher bill.
Step 1: Choose the basics
- Operating system: a current long-term support release of Ubuntu or Debian. Most tutorials and control panels are written for them.
- Size: 1–2 GB of RAM is enough for a few small sites. A busy WordPress store or several sites with a database need more. Start small; most providers let you resize later.
- Location: a data center close to most of your visitors.
- Snapshots: pick a provider that offers automatic snapshots or backups at the server level.
Step 2: Secure access first
Do this before installing anything else. Automated bots start trying to log in to a new server within minutes.
- Create a regular user with sudo rights, and stop working as root.
- Use SSH keys instead of passwords. Generate a key on your computer, copy the public key to the server, test that you can log in with it, and only then disable password login in the SSH configuration.
- Disable root login over SSH.
- Turn on a firewall. With UFW on Ubuntu, allow only SSH, HTTP and HTTPS:
sudo ufw allow OpenSSH sudo ufw allow 80,443/tcp sudo ufw enable - Install Fail2ban to block addresses that keep failing to log in.
- Enable automatic security updates (unattended-upgrades on Ubuntu and Debian).
Step 3: Install the web stack
For a typical PHP site, including WordPress, you need a web server, PHP and a database.
- Web server: Nginx or Apache. Nginx is lighter and very common for new setups. Apache is still everywhere and supports
.htaccessfiles, which many older PHP applications expect. Caddy is a simpler option that handles HTTPS certificates automatically. - PHP: install PHP-FPM with a currently supported version, plus the extensions your application needs (usually mysqli or pdo_mysql, curl, gd or imagick, mbstring, xml, zip, intl).
- Database: MariaDB or MySQL. Run the secure installation script, set a strong root password, and create a separate database user for each site with access only to its own database.
Keep each site in its own directory, with its own configuration file and, ideally, its own system user and PHP-FPM pool. If one site is compromised, the others are not automatically exposed.
To try the same stack on your own computer first, see How to Run PHP and MySQL Locally: A Modern Setup Guide.
Step 4: HTTPS
Every site needs HTTPS. Use Let's Encrypt with Certbot, or Caddy, which does it for you. Certificates renew automatically, but check that renewal works with a dry run, and set up an alert if a certificate is close to expiring. Redirect all HTTP traffic to HTTPS and choose one main version of the domain, with or without www.
Step 5: Backups you have actually tested
A backup you have never restored is a hope, not a backup. A simple plan for small sites:
- Daily database dumps with mysqldump, kept for at least two weeks.
- Daily file backups of uploads and configuration. Code should also live in Git.
- Off-site copies. Send backups to object storage or another provider, not only the same server.
- Provider snapshots as an extra layer, for quick recovery from a bad update.
- A restore test every few months: restore a site to a test server and check that it works.
Step 6: Monitoring
You want to hear about a problem before your client does.
- Uptime monitoring from an outside service that checks each site every few minutes.
- Disk space alerts. Full disks are the most common cause of sudden database errors. Logs and old backups are usually the culprit.
- Log rotation, so access and error logs do not grow forever.
- Resource graphs for CPU, memory and load, so you can see when a site needs a bigger server.
Step 7: Performance basics
- Turn on OPcache for PHP.
- Enable gzip or Brotli compression and HTTP/2 or HTTP/3.
- Set long cache headers for images, CSS and JavaScript files that have versioned names.
- Use page caching for content sites, either in the application or at the server level.
- Consider a CDN for images and static files if visitors come from many countries.
Common problems and where to look
| Symptom | Usual cause | First thing to check |
|---|---|---|
| 502 Bad Gateway | PHP-FPM stopped or crashed | PHP-FPM service status and its error log |
| "Error establishing a database connection" | Database down or wrong credentials | Database service status, disk space |
| Uploads fail | File size limits or folder permissions | upload_max_filesize, client_max_body_size, owner of the uploads folder |
| Site suddenly very slow | Out of memory or a bot flood | Memory usage, access log for repeated requests |
| Certificate warning | Renewal failed | Certbot logs, DNS still pointing to this server |
Security habits after launch
- Update the operating system, PHP, the CMS and plugins on a schedule.
- Remove applications, users and test sites you no longer use.
- Never store passwords or API keys in files inside the public web folder.
- Use parameterized queries in your own code. SQL Injection: What It Is and How to Prevent It explains why.
- Keep the hosting account and the domain registered in the site owner's name.
When to hand it over
If you find yourself spending more time maintaining servers than building sites, that is a sign to move to managed hosting or to hire someone for operations. There is no shame in it; most agencies do exactly that. And if you ever need to move a client's site to a new provider or developer, How to Switch Web Design Companies Without Losing Your Website covers what to hand over.
Comments
Post a Comment