New 24/7 monitoring and daily cloud backups now included in every Shield Pro plan.

Hosting 4th August 2026 14 min read

How to set up a server for WordPress

Share
Neil McNaught, founder of BugShield and WordPress author
Written by
Written by
Updated
Updated

A new VPS needs to be configured before it is ready to host WordPress. This guide covers the web server, PHP, database, security, SSL, backups, and final checks to complete before pointing your domain at it.

What you are building

A production WordPress server usually includes:

  • A web server (Nginx or Apache)
  • PHP-FPM with a supported PHP version
  • MariaDB or MySQL
  • TLS certificates with auto-renewal
  • Firewall and failed-login protections
  • Automated off-server backups
  • Basic monitoring and disk alerts

Step 1: Choose the base and access model

  1. Create the VPS in a region close to your visitors.
  2. Prefer Ubuntu LTS or another long-support distro your team already knows.
  3. Disable password root login. Use SSH keys only.
  4. Create a sudo user for day-to-day work.
  5. Record the provider’s recovery or console access path before you tighten the firewall.

Step 2: Update and harden the OS

  • Apply system updates immediately, then reboot if the kernel changed.
  • Enable automatic security updates or a scheduled patch window you actually run.
  • Configure a firewall: allow SSH, HTTP, and HTTPS only unless you need more ports.
  • Install fail2ban or equivalent and protect SSH.
  • Set the timezone and NTP so logs and cron match reality.

Step 3: Install the WordPress stack

You can use a control panel or a lean CLI stack. Either way, verify the following:

  • Web server serving a temporary hostname or IP test page
  • PHP-FPM connected to the web server with phpinfo() then removed
  • Database server listening on localhost only
  • A dedicated database and user for WordPress with least privilege

Recommended PHP extensions for most modern WordPress sites include mysqli, curl, xml, mbstring, zip, gd or imagick, and intl.

Step 4: Create the site files and permissions

  1. Create a web root such as /var/www/example.com/public.
  2. Download WordPress core into that directory or deploy from your own repo.
  3. Set ownership to the PHP/web user your stack expects.
  4. Use directory permissions around 755 and file permissions around 644.
  5. Keep wp-config.php restrictive and never world-writable.

For permission repairs later, see how to fix WordPress file permissions.

Step 5: Configure HTTPS before launch

  • Point a staging hostname or wait for DNS if you are launching a brand-new domain.
  • Issue certificates with Let’s Encrypt or your provider’s ACME tool.
  • Force HTTPS redirects only after the certificate is valid.
  • Test renewal with a dry run so certificate expiry does not become an outage.

If padlock warnings appear after go-live, use our SSL error how-to and mixed content guide.

Step 6: Hardening WordPress itself

  • Set unique table prefix and strong salts in wp-config.php.
  • Disallow file editing in admin with DISALLOW_FILE_EDIT.
  • Limit XML-RPC if you do not need it.
  • Create an admin user that is not named admin.
  • Put SMTP credentials in a proper mail plugin or transactional provider. Do not rely on bare mail().

Step 7: Backups, cron, and monitoring

System Minimum setup Pass/fail test
Backups Nightly files + database to off-server storage You restore a file and a DB table successfully
Cron System cron hitting wp-cron.php or real cron with DISABLE_WP_CRON Scheduled posts and WooCommerce tasks run
Uptime / health External uptime check + disk/CPU alerts You receive a test alert
Logs Web, PHP, and auth logs rotated You can find a fatal error within minutes

Step 8: Migrate or launch content

  1. Copy files and import the database if migrating.
  2. Search-replace URLs carefully for serialized data.
  3. Update DNS with a lowered TTL planned days ahead.
  4. Flush caches and confirm forms, login, checkout, and webhooks.
  5. Leave the old host online briefly as a rollback path.

Full migration walkthrough: migrate WordPress to a new host. Prefer a developer-owned cutover? Request a BugShield migration.

Common setup mistakes

  • Opening MySQL to the public internet
  • Leaving WP_DEBUG_DISPLAY on for visitors
  • No swap or no disk alerts on small VPS plans
  • Only provider snapshots, never tested application restores
  • Pointing production DNS before HTTPS and mail are ready

Related reading

Quick answers about setting up a WordPress server

Can a beginner set up a WordPress VPS?

It is possible, but this guide assumes basic SSH knowledge and comfort maintaining Linux. If nobody can own security updates, firewalls, backups and recovery, a managed VPS is the safer fit.

Should I use Nginx or Apache for WordPress?

Either can run WordPress well. Choose the web server your team knows how to configure and maintain, then make sure PHP-FPM, redirects, caching and logs are set up correctly.

Which firewall ports should a WordPress server expose?

Most installations only need SSH, HTTP and HTTPS open to the internet. Keep the database bound to the local server and open any extra port only when a real service requires it.

Is a provider snapshot enough to protect WordPress?

No. Keep scheduled off-server backups of the WordPress files and database as well. Test a restore so you know the data can be recovered before an emergency.

When should I point the domain at the new server?

Wait until WordPress, HTTPS, mail, backups and monitoring have been tested. Lower the DNS TTL ahead of the move, rehearse the cutover and keep the old host available briefly in case you need to roll back.