Abdulrahman EldiehyWordPress Security Specialist
All guidesPrevention and hardening

Hardening WordPress, step by step

From updates and backups to permissions, headers and monitoring, with prioritized hardening you can apply today.

11 min readUpdated

Before you start

Have these ready before you work through the steps:

  • A recent backup you've tested restoring
  • Full admin access to WordPress and hosting
  • A quiet window for sensitive changes
01

Updates first

Most hacks don't come from sophisticated attacks but from known flaws in plugins or themes that weren't updated. So hardening starts here, before any security plugin.

  1. UpdatesClose known holes
  2. AccountsTwo-factor, least privilege
  3. FilesNo editing, no PHP in uploads
  4. TransportHTTPS and security headers
  5. Backups & monitoringTested restores and alerts
Layers that back each other up; never rely on just one, however strong.

Turn on automatic security updates for core, update plugins and themes only from their official sources, and delete everything you don't use; a deactivated plugin is still on the server and can be exploited.

Avoid nulled copies of premium plugins entirely; they're one of the most common ways backdoors get planted. If a plugin has been abandoned for years with no updates, look for an alternative.

Components that need updating
wp plugin list --update=available && wp theme list --update=available

Start with security releases, then the rest in stages.

02

Accounts and permissions

Every admin account is a full door into your site. Keep admins to a minimum and give everyone else lower roles, such as editor or author, based on what they actually need.

  • AdministratorEverything
  • EditorAll content
  • AuthorOwn posts only
  • SubscriberOwn profile
Fewer admins means fewer open doors. Give each person only the role they need.

Turn on two-factor login for every admin, use long unique passwords from a password manager, and remove former staff and temporary developers as soon as their work ends.

Review the user list monthly; a forgotten account, or one you don't know who created, is among the first things an attacker looks for.

03

Files and execution

Disable theme and plugin file editing from the dashboard, so that if an admin account is stolen the attacker can't plant code straight from the browser.

Block PHP execution inside the uploads folder, which is meant for images and files only; any PHP there is a red flag. Set file permissions: 644 for files, 755 for folders, and 600 for wp-config.php where your host allows it.

Disable dashboard editing (wp-config.php)
define( 'DISALLOW_FILE_EDIT', true );

Add it above the "That's all, stop editing" line.

Block PHP in uploads (Apache)
# wp-content/uploads/.htaccess
<FilesMatch "\.(php|phtml|phar)$">
  Require all denied
</FilesMatch>

On Nginx this is set in the server configuration instead.

04

Headers and secure transport

Make the whole site run on HTTPS with no exceptions, and fix any images or scripts still loading over http.

Once HTTPS is stable, enable HSTS and add basic security headers such as X-Frame-Options and X-Content-Type-Options, then a CSP tuned to your site. Generate the snippet with the headers tool here and test it on staging first; a wrong CSP can break parts of the site.

05

Backups and monitoring

A backup you've never tried restoring isn't a backup. Keep daily off-site copies, more than one older version, and test a restore every few months on a staging site.

3copies of your data
2on two different media
1off the server
plus a tested restore every few months
The 3-2-1 rule: a backup you've never restored isn't a backup.

Turn on alerts for account and file changes, and keep an eye on Search Console; catching problems early makes them much smaller and cheaper.

Common questions

A few questions, answered

No. A plugin is a helper layer; the foundation is updates, backups and correct permissions. No plugin makes a neglected site secure.

Fair. The rule: a backup, then a test on staging, then gradual updates starting with security releases.

It cuts automated guessing, but it doesn't fix any vulnerability. Two-factor login and strong passwords matter far more.

Updates weekly, users and backups monthly, and a full restore test every few months.

Nobody can honestly promise that. But it closes the routes most attacks use, and makes detection and recovery faster.

Further reading

Let’s get your site clean again.

Tell me what you're seeing on your site in your own words, no technical terms needed, and I'll tell you the next step clearly.