wordpress on a vps setup guide - featured image

WordPress on a VPS Setup Guide: 7 Proven Fixes

This WordPress on a VPS setup guide is for store owners who left shared hosting for speed and control, then found themselves staring at 502 errors, a blank checkout or a server that falls over every evening. While that happens, carts are abandoned and customers quietly shop elsewhere. The good news: almost every VPS problem traces back to a handful of setup decisions, and each one has a clear fix.

See how our Server Management service handles this →

Quick answer: To run WordPress on a VPS reliably, use a supported Linux release, Nginx or Apache with PHP-FPM, a tuned MariaDB or MySQL database, correct file ownership, free SSL, a firewall with key-only SSH, page and object caching, real SMTP email and automated off-server backups. Most VPS failures come from skipping one of these.

Before you start: what this WordPress on a VPS setup guide assumes

A VPS is a blank machine. Unlike shared hosting, nobody patches it, tunes it or watches it for you. That freedom is exactly why it is faster, and it is also why small gaps turn into outages.

Throughout this WordPress on a VPS setup guide we assume a typical small-store server:

  • At least 2 GB of RAM (4 GB is far more comfortable for WooCommerce).
  • A current long-term-support Linux release, such as Ubuntu LTS or Debian stable.
  • Root or sudo access over SSH.
  • A recent full backup of your files and database, stored somewhere other than the server.

If you do not have that backup yet, stop and make one first. Our guide on how to restore a WordPress site from backup explains what a usable backup actually contains.

1. The wrong stack for your traffic (slow pages from day one)

Symptom

Pages take two to five seconds to load even with almost no visitors, and the admin feels sluggish.

Why it happens

Many owners install whatever a random tutorial suggested: an old PHP version, Apache running mod_php, or a one-click image packed with services they never use. As a result, memory is used up before WordPress even starts. A good WordPress on a VPS setup guide starts with a lean stack for exactly this reason.

How to check

  1. Run php -v and confirm you are on a supported PHP 8.x release.
  2. Run systemctl list-units --type=service --state=running to see what is actually running.
  3. Compare your versions against the official WordPress server requirements.

How to fix it

  • Run PHP-FPM behind Nginx, or behind Apache with the event MPM, instead of using mod_php.
  • Install only the PHP extensions WordPress and WooCommerce need (curl, mbstring, xml, zip, intl, gd or imagick, mysqli).
  • Disable services you do not use, such as a bundled mail server or FTP daemon.

Upgrading PHP on a live store needs care, so follow our steps to update your PHP version in WordPress safely before you switch.

2. PHP-FPM misconfigured (502 and 504 errors under load)

Symptom

The site works fine at quiet times, then throws “502 Bad Gateway” or “504 Gateway Timeout” during a sale or an email campaign.

Why it happens

PHP-FPM ships with a small default pool. When more requests arrive than there are PHP workers, the web server waits, gives up and returns an error. Set the worker count too high, though, and the server runs out of RAM. Almost every WordPress on a VPS setup guide glosses over this balance, yet it decides how your store behaves on busy days.

How to check

  1. Look in the PHP-FPM log (usually under /var/log/) for “server reached pm.max_children”.
  2. Check the web server error log for “upstream timed out” or “connect() failed”.
  3. Run free -m during busy periods to see how much memory is left.

How to fix it

  1. Measure the average memory used by one PHP-FPM process (commonly 60–120 MB for WooCommerce).
  2. Divide the RAM you can spare for PHP by that number. The result is your safe pm.max_children.
  3. Set pm = dynamic or ondemand, and raise request_terminate_timeout a little, for example to 120 seconds.
  4. Reload PHP-FPM and watch the logs during the next busy hour.

If single requests die with “Allowed memory size exhausted”, that is a different limit. Our WordPress memory exhausted error fix covers it step by step.

3. Database killed by the system (random connection errors)

Symptom

The site goes down at random with “Error establishing a database connection”, then comes back after a restart.

Why it happens

On a small VPS, MySQL or MariaDB usually uses more memory than anything else. When RAM runs out and there is no swap, the Linux out-of-memory killer stops the database to protect the system. Your store goes offline instantly.

How to check

  • Run journalctl -k | grep -i oom or dmesg -T | grep -i "killed process".
  • Run swapon --show. If it prints nothing, the server has no swap at all.

How to fix it

  1. Add a modest swap file (1–2 GB) as a safety net, not as extra RAM.
  2. Set innodb_buffer_pool_size to roughly 40–50% of RAM on a server that also runs PHP, rather than the 70–80% often suggested for dedicated database servers.
  3. Lower max_connections to a realistic number, such as 50–100.
  4. Clear expired transients and old WooCommerce sessions so the database stays lean.

In short, this WordPress on a VPS setup guide treats swap and buffer sizing as mandatory, not optional.

4. Wrong file ownership and permissions (updates ask for FTP details)

Symptom

WordPress asks for FTP credentials when you update a plugin, uploads fail, or images never appear in the media library.

Why it happens

The files were copied in as root, so the PHP process cannot write to them. Or someone “fixed” the problem with chmod 777, which works but leaves the site wide open. That is why any WordPress on a VPS setup guide worth following sets ownership before the first plugin install.

How to check

  • Run ls -la in your web root and note who owns the files.
  • Run ps aux | grep php-fpm to see which user PHP runs as.

How to fix it

  1. Give ownership of the files to the user the PHP-FPM pool runs as. Ideally that is a dedicated user for each site, and never root.
  2. Set directories to 755 and files to 644.
  3. Tighten wp-config.php to 640 or 600.
  4. Never use 777 anywhere on a production server.

5. SSL, DNS and redirect loops (site “not secure” or won’t load)

Symptom

Browsers show “Not secure”, the site loops between http and https, or the domain still points to the old host.

Why it happens

Typically, one of three things went wrong: the certificate was requested before DNS pointed to the new server, nobody tested auto-renewal, or the WordPress Address and Site Address still use http. A CDN proxy set to “flexible” SSL also causes endless redirects. A reliable WordPress on a VPS setup guide always does DNS first and the certificate second.

How to check

  • Run dig +short yourdomain.com and confirm it returns your VPS IP (or your CDN’s IPs).
  • Run certbot certificates to see expiry dates.
  • Check Settings → General for http vs https URLs.

How to fix it

  1. Once DNS has propagated, issue a free Let’s Encrypt certificate with Certbot.
  2. Test renewal with certbot renew --dry-run.
  3. Set both site URLs to https, then run a careful search-replace on the database to update old http links.
  4. If you use a CDN proxy, set its SSL mode to full (strict).

Moving to a new domain at the same time? Use our checklist to change your WordPress domain without losing SEO.

6. No hardening (brute-force attacks, high CPU, hacked sites)

Symptom

CPU stays high with no real visitors, the logs fill with login attempts, or you find admin users you don’t recognise.

Why it happens

Bots start scanning a new VPS within minutes of it going online. Password-based root SSH, open database ports and an unprotected xmlrpc.php make it an easy target. Sadly, this is the step a rushed WordPress on a VPS setup guide most often skips.

How to check

  • Run sudo ss -tulpn to list open ports. MySQL (3306) should not be public.
  • Look in /var/log/auth.log for repeated failed SSH logins.

How to fix it

  1. Enable a firewall (UFW or nftables) and allow only SSH, HTTP and HTTPS.
  2. Switch SSH to key-only login and disable root login.
  3. Install Fail2ban to block repeated failed logins for SSH and wp-login.php.
  4. Turn on unattended security updates for the operating system.
  5. Give each person their own account with only the access they need.

7. Missing caching, email and backups (the “it works, but…” problems)

Symptom

The site is up, yet it is slower than expected, order emails land in spam or never arrive, and nobody knows when the last backup ran.

Why it happens

A VPS does none of this for you. PHP’s built-in mail() sends from an unauthenticated IP, so inbox providers distrust it. Meanwhile, without page or object caching, the server rebuilds every page from scratch for each visitor.

How to fix it

  • Caching: enable OPcache, add Redis as a persistent object cache, and use a page cache that excludes the cart, checkout and account pages.
  • Email: send through an authenticated SMTP or transactional email service, and publish SPF, DKIM and DMARC records.
  • Backups: schedule daily database and file backups to off-server storage, keep several versions, and test a restore at least once.
  • Monitoring: add uptime alerts so you hear about downtime before your customers do.

Once these four items are done, the checklist in this WordPress on a VPS setup guide is complete.

Quick troubleshooting table

Use this table to match what you see to the section of this WordPress on a VPS setup guide that fixes it.

SymptomLikely causeQuick fix
Slow pages with low trafficOld PHP, mod_php, bloated stackMove to PHP-FPM on a supported PHP 8.x release
502 / 504 during salesPHP-FPM pool too smallCalculate and raise pm.max_children
“Error establishing a database connection”Out-of-memory killer stopped MySQLAdd swap, resize the InnoDB buffer pool
Updates ask for FTP detailsWrong file ownershipMake the PHP-FPM user the file owner; set 755/644
“Not secure” or redirect loopSSL issued too early or http URLsReissue certificate, set https URLs, use full (strict) mode
High CPU with no visitorsBots attacking SSH or wp-loginFirewall, key-only SSH, Fail2ban
Order emails missingUnauthenticated PHP mailSMTP service plus SPF, DKIM, DMARC

When to call in a pro

Following a WordPress on a VPS setup guide yourself is a great way to learn, but a live store is a risky place to experiment. Maybe you have worked through the causes above and the errors keep coming back. Or maybe you would rather spend your time selling. Either way, it makes sense to hand the server over.

Our WordPress server management service covers exactly this:

  • Linux / VPS setup or takeover, documented, so you know what is installed and why.
  • Hardening: firewall, SSH and least access.
  • Performance tuning for real traffic, not just a quiet test day.
  • A setup you fully own.
  • Pricing from $160.

Not sure which of these causes is behind your problem? Describe what you are seeing on WhatsApp and we will reply with a no-obligation quote.

Not sure which fix you need? Send us your store.

Leave your name and what is happening on WhatsApp — we diagnose it, talk it through and send you a quote. No obligation, no jargon.

Message us on WhatsApp

Frequently asked questions

How much RAM do I need for WordPress on a VPS?

A simple brochure site runs on 1–2 GB. For WooCommerce, 4 GB is a sensible starting point, because PHP-FPM workers and the database both need headroom during busy periods.

Is a VPS faster than shared hosting for WordPress?

Usually, yes, because the resources are yours alone. However, an untuned VPS can easily be slower than good shared hosting. Speed comes from configuration, not just the server.

Should I use a control panel or set up the server by hand?

A control panel makes routine tasks easier and suits owners who want a visual dashboard. A hand-built stack uses fewer resources and gives you more control. Either way, every step in this WordPress on a VPS setup guide still applies.

Can I move my existing store to a VPS without downtime?

Yes. Build and test the new server first, and lower your DNS TTL a day in advance. Next, copy the files and database across, then do a final sync and switch DNS during a quiet hour.

How often should a VPS be maintained?

Security updates should install automatically every day. On top of that, a sensible WordPress on a VPS setup guide routine is to review logs, backups, disk space and PHP versions at least once a month.

Similar Posts