LOGO
Core Dynexiz Technology • Education • Innovation
Core Dynexiz

10 Ways to Secure Your WordPress Website: A Practical Security Guide

Home / 10 Ways to Secure Your WordPress Website: A Practical Security Guide

Introduction

WordPress website security requires more than installing a security plugin and assuming everything is protected. A stronger approach combines WordPress configuration, authentication security, database protection, server-level controls, backups, and continuous monitoring.

In our previous article, “Myth: A New Website Is Too Small for Hackers to Care About,” we discussed why even new and low-traffic websites can receive automated login attempts, vulnerability scans, and other malicious traffic.

WordPress security is not about installing one security plugin and assuming everything is protected. A stronger approach combines WordPress configuration, authentication security, database protection, server-level controls, backups, and continuous monitoring.

This guide covers 10 practical security measures that can significantly strengthen a production WordPress website.

1. Keep WordPress Core, Plugins, and Themes Updated

One of the simplest security measures is also one of the most important: keep your software updated.

Your WordPress installation consists of several components:

  • WordPress core
  • Plugins
  • Themes
  • PHP and server software

Security vulnerabilities are regularly discovered and fixed through updates. Running outdated components may leave known vulnerabilities available to automated scanners.

However, updates should be performed carefully on production websites.

A Practical Update Workflow

Backup → Update → Test Website → Verify Logs

Also remove plugins and themes you no longer use. Every unnecessary component increases the amount of code that must be maintained and monitored.

Install only what you need, and keep what you install updated.

2. Protect the Administrator Account with Strong Authentication

Administrator accounts have extensive control over WordPress, making them especially important to protect.

Start with a strong, unique password that is not reused on other websites. Then enable Two-Factor Authentication (2FA).

Add a Second Authentication Layer

Username + Password + Temporary Authenticator Code

Even if an attacker obtains the password, they still need the second authentication factor. Security plugins such as AIOS can provide login protection and TOTP-based two-factor authentication.

After enabling 2FA, always test it in a private/incognito browser before closing your existing Administrator session.

Also periodically check:

WordPress Admin → Users → All Users

You should recognize every Administrator account. An Administrator you did not create should be treated as a serious security event.

3. Disable Public User Registration When It Is Not Required

Many company websites, portfolios, blogs, and informational WordPress websites do not require public accounts.

Go to:

WordPress Admin → Settings → General → Membership

If visitors do not need accounts, make sure Anyone can register is unchecked.

This does not protect against every possible method of unauthorized account creation if the website itself is compromised, but it removes an unnecessary registration feature.

If you don’t need a feature, don’t expose it unnecessarily.

4. Protect WordPress Authentication Keys and Salts

WordPress uses authentication keys and salts as part of its cookie and session security.

They are configured inside wp-config.php. A new configuration file may contain placeholder values such as:

define( 'AUTH_KEY', 'put your unique phrase here' );

These placeholders should be replaced with strong random values. WordPress provides an official generator:


WordPress Secret-Key Generator →

The generated values should remain private.

If you suspect that a website or Administrator session has been compromised, generating new keys and salts is also useful because it invalidates existing WordPress authentication cookies, requiring users to log in again.

Rotating WordPress authentication keys and salts can help terminate sessions that should no longer be trusted.

5. Use a Dedicated Database User Instead of MySQL Root

WordPress needs database credentials, but the application should not normally connect using the MySQL root account.

Instead, create a dedicated user for the WordPress database.

Create a Dedicated Database User

CREATE USER 'wordpress_user'@'localhost'
        IDENTIFIED BY 'STRONG_RANDOM_PASSWORD';

Then grant access only to the required WordPress database:

GRANT ALL PRIVILEGES
        ON wordpress_database.*
        TO 'wordpress_user'@'localhost';

Verify the permissions:

SHOW GRANTS FOR 'wordpress_user'@'localhost';

Then configure the dedicated database credentials in wp-config.php.

Limit WordPress Database Access

WordPress → Dedicated DB User → WordPress Database

instead of

WordPress → MySQL Root → Entire Database Server

This follows the principle of least privilege.

If WordPress database credentials are ever exposed, limiting the account’s scope can reduce the potential impact.

6. Disable Theme and Plugin File Editing

WordPress can allow Administrators to modify theme and plugin files directly from the dashboard.

On a production website where code is managed through Git, SSH, SFTP, or another controlled deployment process, this capability may not be necessary.

Disable the Built-in File Editors

Add the following to wp-config.php:

define( 'DISALLOW_FILE_EDIT', true );

This disables the built-in WordPress theme and plugin editors.

Optional: Restrict File Modifications

For a temporary security lockdown, you can go further:

define( 'DISALLOW_FILE_MODS', true );

This prevents plugin and theme installation, deletion, and updates through WordPress Admin.

Use DISALLOW_FILE_MODS carefully because it also prevents legitimate dashboard updates. It is better suited to controlled deployment environments or temporary incident containment.

7. Prevent PHP Execution Inside the Uploads Directory

The WordPress uploads directory normally contains media and downloadable files such as:

  • Images
  • PDFs
  • Documents
  • Spreadsheets
  • Videos
  • Other media files

It generally should not execute PHP application code. On an Apache-based WordPress server, you can add an .htaccess file inside:

wp-content/uploads/.htaccess

Add a rule such as:

<FilesMatch "\.(?i:php|phtml|phar|php3|php4|php5|php7|php8)$">
            Require all denied
        </FilesMatch>

This adds an important security boundary. If a malicious PHP file somehow reaches the uploads directory, Apache should refuse web access to files matching this rule.

Validate and Test the Configuration

After making Apache configuration changes, validate the configuration:

apache2ctl configtest

You want to see:

Syntax OK

Then test the restriction with a harmless test file rather than assuming the rule works as expected.

Security controls should be tested, not merely configured.

8. Disable XML-RPC If Your Website Does Not Need It

WordPress includes xmlrpc.php for certain remote communication features. If your website does not use functionality that depends on XML-RPC, you can consider blocking it.

Block XML-RPC on Apache

Add the following rule to your site’s .htaccess file:

<Files "xmlrpc.php">
            Require all denied
        </Files>

Place custom rules outside the WordPress-generated section of .htaccess, because WordPress may rewrite content between these markers:

# BEGIN WordPress
        ...
        # END WordPress

Validate and Test the Change

Validate the Apache configuration:

apache2ctl configtest

If the configuration is valid, reload Apache:

systemctl reload apache2

Finally, request /xmlrpc.php and confirm that access is denied.

Do not disable XML-RPC blindly. First confirm that your website does not use a service or feature that depends on it.

9. Maintain Off-Site Backups and Know How to Rebuild

A backup stored only on the production server is not enough. If the server is compromised, deleted, corrupted, or inaccessible, the backup may be affected as well.

What Should You Protect?

  • WordPress database
  • Uploads and media files
  • Custom theme
  • Custom code
  • Important configuration

Keep at least one copy outside the production server, such as secure local storage or a trusted backup service.

For custom development, keeping your theme or application code in a private Git repository also provides a trusted source from which the code can be redeployed.

Understand the difference between restoring legitimate data and restoring potentially compromised executable code.

After a serious compromise, a safer recovery process may look like:

Preserve Evidence & Backups
→ Deploy Fresh WordPress Core
→ Install Plugins from Trusted Sources
→ Deploy Trusted Custom Code
→ Restore Legitimate Uploads
→ Review the Database
→ Rotate Credentials & Salts
→ Harden
→ Monitor

Blindly restoring the entire compromised website can also restore the attacker’s modifications.

10. Monitor Security Logs — Don’t Just Install Security Tools

Security does not end after configuration. You also need to monitor what happens afterward.

WordPress Security Logs

A WordPress security plugin can record events such as:

  • Failed and successful logins
  • User registrations and deletions
  • Account changes
  • IP addresses
  • Timestamps

Server Access Logs

Apache access logs provide another layer of information:

  • IP address and request time
  • HTTP method and requested URL
  • HTTP status code
  • User agent

The most important distinction is between an attack attempt and a successful compromise.

Failed login — Unknown username
May simply mean a bot attempted to authenticate and WordPress rejected it.

Successful login — Unfamiliar IP / New Administrator account
Requires immediate investigation.

Do not spend all your time manually blocking every suspicious IP. Automated attacks can rotate through many different addresses. Focus instead on whether your security controls are preventing unauthorized actions.

Failed attacks are expected. Unauthorized successful actions are not.

A Practical WordPress Security Model

Instead of relying on one feature, think of your WordPress security as multiple layers working together.

Updated Software

Strong Credentials

Two-Factor Authentication

Limited User Access

Secure Database Account

Authentication Keys & Salts

Restricted File Modification

Uploads Protection

Firewall

Off-Site Backups

Continuous Monitoring

This approach is known as defense in depth. If one security layer fails, another may prevent the attacker from progressing further or help reduce the potential damage.

What If You Discover an Unknown Administrator?

This deserves special attention. Suppose you open:

WordPress Admin → Users → All Users

and discover an Administrator account that you never created. Do not simply delete it and assume the problem is solved.

First preserve useful logs and evidence, then investigate:

When Was the Account Created?

Which IP Was Involved?

Was There a Successful Login?

Were Files Changed?

Were Plugins or Themes Installed?

Were Posts or Settings Modified?

Is There Another Persistence Mechanism?

Then rotate credentials, invalidate existing sessions, inspect the database and filesystem, replace questionable executable files with trusted copies, and continue monitoring the website.

The important question is not only:

“How do I delete this user?”

It is:

“How did this user get created?”

Final Thoughts

WordPress security is not one setting, one plugin, or one firewall rule. A practical security strategy combines multiple layers of protection.

Updates + Strong Authentication + 2FA + Least Privilege + Secure Configuration + Backups + Monitoring

You cannot prevent every bot from requesting your website or attempting a login. Your objective is to make sure those attempts do not become successful compromises.

And if something does go wrong, your backups, logs, trusted source code, and recovery process should allow you to respond quickly.

Good website security is not about making attacks disappear. It is about making your website difficult to compromise and easier to recover.