Skip to main content

Enhancing WordPress Security

10 min read
Harden my WordPress site

We set up two-factor login, login limits, wp-config hardening and backups on your site.

A comprehensive guide to securing WordPress sites, covering updates, strong passwords, hosting, two-factor authentication, security plugins, SSL, login limits, wp-config hardening, and backups.

Overview

WordPress powers over 40% of all websites on the internet, which makes it a high-value target for attackers. Keeping a WordPress site secure is essential to protect data, maintain visitor trust, and prevent costly downtime. This guide covers best practices, essential plugins, and step-by-step instructions for hardening a WordPress installation against common threats.

1. Keep WordPress Updated

Regularly updating WordPress core, themes, and plugins is the first line of defense against security vulnerabilities. Updates often patch known exploits, so delaying them leaves the site exposed.

  • Navigate to Dashboard > Updates to check for available updates.
  • Enable auto-updates for minor releases to ensure critical patches are applied quickly.
  • Test updates in a staging environment before applying them to production.

2. Use Strong Passwords and User Permissions

Weak passwords and improper user roles make it easy for unauthorized users to gain access.

Implementing Strong Passwords

  • Use complex passwords that combine uppercase, lowercase, numbers, and symbols.
  • Consider a password manager to generate and store credentials securely.
  • Enforce strong password policies for all user accounts.

Managing User Roles

  • Assign the minimum permissions necessary for each user.
  • Regularly audit user accounts and remove inactive ones.
  • Avoid using the default "admin" username.

3. Choose a Secure Hosting Provider

The hosting environment plays a significant role in overall security. We recommend looking for providers that offer server-level firewalls, intrusion detection, regular backups, and support for the latest PHP and MySQL versions.

4. Enable Two-Factor Authentication (2FA)

Adding a second layer of authentication significantly reduces the risk of unauthorized access, even if a password is compromised. Plugins such as Google Authenticator or Wordfence can add 2FA to the WordPress login flow.

5. Install Security Plugins

Security plugins provide additional protection by monitoring for and blocking malicious activity:

  • Wordfence Security -- Firewall, malware scanner, and login security.
  • Sucuri Security -- Auditing, malware scanning, and security hardening.
  • iThemes Security -- Brute-force protection, file change detection, and 2FA.

6. Use an SSL Certificate

An SSL certificate encrypts data transmitted between the site and its visitors, protecting sensitive information in transit. SSL also improves search engine rankings and builds visitor trust via the padlock icon.

7. Limit Login Attempts

Limiting login attempts helps prevent brute-force attacks. Plugins like Limit Login Attempts Reloaded or the built-in Wordfence feature can lock out IP addresses after repeated failed attempts.

8. Secure the wp-config.php File

The wp-config.php file contains sensitive information such as database credentials and security keys. We can protect it with an .htaccess rule:

<Files wp-config.php>
    Order Allow,Deny
    Deny from all
</Files>

We also recommend moving wp-config.php one directory above the web root when the hosting environment allows it.

9. Disable XML-RPC

XML-RPC can be exploited for brute-force attacks and DDoS amplification. Unless we specifically need it for remote publishing or the Jetpack plugin, we should disable it via .htaccess:

<Files xmlrpc.php>
    Order Deny,Allow
    Deny from all
</Files>

10. Regularly Back Up the Site

Regular backups ensure we can restore the site in case of a security breach or data loss:

  • Use plugins such as UpdraftPlus or BackupBuddy for automated backups.
  • Store backups off-site in a cloud service like Amazon S3 or Google Drive.
  • Test restores periodically to verify backup integrity.

Securing a WordPress site is an ongoing effort that requires a multi-layered approach. By implementing the strategies outlined here -- keeping software updated, enforcing strong credentials, hardening configuration files, and maintaining reliable backups -- we significantly reduce the risk of security breaches. We recommend reviewing these measures regularly and adapting them as new threats emerge.

Frequently asked questions

How should I handle WordPress updates for security?

Updates to WordPress core, themes and plugins are the first line of defense, because they often patch known exploits. Check Dashboard > Updates regularly and enable auto-updates for minor releases so critical patches arrive quickly. Test updates in a staging environment before applying them to production.

How do I add two-factor authentication to a WordPress login?

Install a plugin that adds 2FA to the login flow, such as Google Authenticator or Wordfence. iThemes Security includes 2FA as well. A second factor significantly lowers the risk of unauthorized access, even when a password has already been compromised.

Which WordPress security plugins are worth installing?

Wordfence Security provides a firewall, a malware scanner and login security. Sucuri Security focuses on auditing, malware scanning and security hardening. iThemes Security covers brute-force protection, file change detection and 2FA. Each one monitors for malicious activity and blocks it.

How do I protect wp-config.php from being read over the web?

Add a Files directive for wp-config.php to the .htaccess file with Order Allow,Deny and Deny from all. Apache then refuses web requests for the file that holds the database credentials and security keys. Where the hosting environment allows it, also move wp-config.php one directory above the web root.

Should I disable XML-RPC on WordPress?

Disable XML-RPC unless the site specifically needs it for remote publishing or the Jetpack plugin. The xmlrpc.php endpoint can be exploited for brute-force attacks and DDoS amplification. Block it in .htaccess with a Files directive for xmlrpc.php that uses Order Deny,Allow and Deny from all.

How do I protect WordPress logins from brute-force attacks?

Limit login attempts so an IP address is locked out after repeated failures, using Limit Login Attempts Reloaded or the built-in Wordfence feature. Avoid the default "admin" username and use complex passwords that mix uppercase, lowercase, numbers and symbols. A password manager makes those passwords practical to generate and store.

Does a WordPress site need an SSL certificate?

An SSL certificate encrypts the data travelling between a WordPress site and its visitors, which protects sensitive information in transit. SSL also improves search engine rankings and shows the padlock icon that builds visitor trust.

How should WordPress backups be set up?

Automate backups with a plugin such as UpdraftPlus or BackupBuddy and store the copies off-site, for example in Amazon S3 or Google Drive. Test a restore periodically to verify backup integrity. Working backups are what make it possible to restore the site after a security breach or data loss.

Read how we handle it in DevOps for e-commerce.