The Ultimate WordPress Security Guide – Step by Step (2024)

WordPress security is a topic of huge importance for every website owner.

If you are serious about your website, then you need to pay attention to WordPress security best practices. Otherwise, you may become one of the 10,000+ websites Google blacklists every day for malware and phishing.

In this guide, we will share our top WordPress security tips to help you protect your website against hackers and malware.

The Ultimate WordPress Security Guide - Step by Step

While WordPress core software is very secure and is audited regularly by hundreds of developers, there’s still a lot that needs to be done to keep your site secure.

At WPBeginner, we believe that security is not just about risk elimination. It’s also about risk reduction. As a website owner, there’s a lot that you can do to improve your WordPress security, even if you are not tech-savvy.

That’s why we put together a list of actionable steps that you can take to protect your website against security vulnerabilities.

💡Need help managing your WordPress site? Let WPBeginner experts handle all WordPress technicalities. Backups, updates, security – we’ve got it covered. We keep your site running smoothly so you can spend your time on what truly matters.

→ Get Our WordPress Maintenance Service Today! ←

To make it easy, we have created a table of contents to help you easily navigate through our ultimate WordPress security guide.

Table of Contents

Basics of WordPress Security

  • Why WordPress Security Is Important
  • Keep WordPress Updated
  • Use Strong Passwords and User Permissions
  • Understand the Role of WordPress Hosting

WordPress Security in Easy Steps (No Coding)

  • Install a WordPress Backup Solution
  • Install a Reputable WordPress Security Plugin
  • Enable a Web Application Firewall (WAF)
  • Move Your WordPress Site to SSL/HTTPS

WordPress Security for DIY Users

  • Change the Default Admin Username
  • Disable File Editing
  • Disable PHP File Execution in Certain WordPress Directories
  • Limit Login Attempts
  • Add Two Factor Authentication (2FA)
  • Change the WordPress Database Prefix
  • Password Protect WordPress Admin and Login Page
  • Disable Directory Indexing and Browsing
  • Disable XML-RPC in WordPress
  • Automatically Log Out Idle Users in WordPress
  • Add Security Questions to WordPress Login
  • Scan WordPress for Malware and Vulnerabilities
  • Fix a Hacked WordPress Site

Ready? Let’s get started.

Why Website Security Is Important

A hacked WordPress website can cause serious damage to your business’s revenue and reputation. Hackers can steal user information and passwords, install malicious software, and even distribute malware to your users.

Worst, you may find yourself paying ransomware to hackers just to regain access to your website.

Ransomware Attack

Every day, Google warns 12-14 million users that a website they are trying to visit may contain malware or steal information.

Furthermore, Google blacklists around 10,000+ websites each day for malware or phishing.

Just as business owners with a physical location have the responsibility of safeguarding their property, online business owners need to pay extra attention to their WordPress security.

Keep WordPress Updated

Easily update WordPress

WordPress is open-source software and is regularly maintained and updated. By default, WordPress automatically installs minor updates.

For major releases, you need to manually initiate the update.

WordPress also comes with thousands of plugins and themes that you can install on your website. These plugins and themes are maintained by third-party developers, which regularly release updates as well.

These WordPress updates are crucial for the security and stability of your WordPress site. You need to make sure that your WordPress core, plugins, and theme are up to date.

Use Strong Passwords and User Permissions

Manage strong passwords

The most common WordPress hacking attempts use stolen passwords. You can make that difficult by using stronger passwords that are unique to your website.

We are not just talking about the WordPress admin area. Remember to create strong passwords for your FTP accounts, databases, WordPress hosting accounts, and custom email addresses that use your site’s domain name.

Many beginners don’t like using strong passwords because they are hard to remember. The good thing is that you don’t need to remember passwords anymore because you can just use a password manager.

See our guide on how to manage WordPress passwords for more information.

Another way to reduce the risk is to not give anyone access to your WordPress admin account unless you absolutely have to.

If you have a large team or guest authors, then make sure that you understand user roles and capabilities in WordPress before you add new user accounts and authors to your WordPress site.

Understand the Role of WordPress Hosting

WP Engine WordPress Hosting Homepage

Your WordPress hosting service plays the most important role in the security of your WordPress site. A good shared hosting provider like Hostinger, Bluehost, or SiteGround takes extra measures to protect their servers against common threats.

Here are just a few ways that good web hosting companies work in the background to protect your websites and data:

  • They continuously monitor their network for suspicious activity.
  • All good hosting companies have tools in place to prevent large-scale DDoS attacks.
  • They keep their server software, PHP versions, and hardware up to date to prevent hackers from exploiting a known security vulnerability in an old version.
  • They have ready-to-deploy disaster recovery and accident plans that allow them to protect your data in case of a major accident.

On a shared hosting plan, you share the server resources with many other customers. There is a risk of cross-site contamination where a hacker can use a neighboring site to attack your website.

By contrast, using a managed WordPress hosting service provides a more secure platform for your website. Managed WordPress hosting companies offer automatic backups, automatic WordPress updates, and more advanced security configurations to protect your website

We recommend WP Engine as our preferred managed WordPress hosting provider. They are also the most popular provider in the industry.

Make sure you get the best deal by using our special WP Engine coupon.

WordPress Security in a Few Easy Steps (No Coding)

We know that improving WordPress security can be a terrifying thought for beginners, epecially if you are not techy. Guess what – you are not alone.

We have helped thousands of WordPress users in hardening their WordPress security.

We will show you how you can improve your WordPress security with just a few clicks (no coding required).

If you can point-and-click, you can do this!

1. Install a WordPress Backup Solution

WordPress Backup

Backups are your first defense against any WordPress attack. Remember, nothing is 100% secure. If government websites can be hacked, then so can yours.

Backups allow you to quickly restore your WordPress site in case something bad was to happen.

There are many free and paid WordPress backup plugins that you can use. The most important thing you need to know when it comes to backups is that you must regularly save full-site backups to a remote location (not your hosting account).

We recommend storing it on a cloud service like Amazon, Dropbox, or private clouds like Stash.

Based on how frequently you update your website, the ideal setting might be either once a day or real-time backups.

Thankfully this can be easily done by using plugins like Duplicator, UpdraftPlus, or BlogVault. They are both reliable and most importantly easy to use (no coding needed).

For more details, see our guide on how to back up your WordPress website.

Install a Reputable WordPress Security Plugin

After backups, the next thing we need to do is set up an auditing and monitoring system that keeps track of everything that happens on your website.

This includes file integrity monitoring, failed login attempts, malware scanning, and more.

Thankfully, you can easily take care of this by installing one of the best WordPress security plugins, such as Sucuri.

You need to install and activate the free Sucuri Security plugin. For more details, please see our step-by-step guide on how to install a WordPress plugin.

Now, you can head over to the Sucuri Security » Dashboard to see if the plugin found any immediate issues with your WordPress code.

Setting up the Sucuri WordPress security plugin

The next thing you need to do is navigate to the Sucuri Security » Settings page and click on the ‘Hardening’ tab.

The default settings work well for most websites, so you can go ahead and activate them by clicking the ‘Apply Hardening’ button for each option.

Hardening your WordPress blog or website

This helps you lock down the key areas hackers often use in their attacks.

Tip: We will cover further ways to harden your website later in this article, such as changing the database prefix and admin username. However, these are more technical and may require coding knowledge.

After the hardening part, the plugin’s other default settings are good enough for most websites and don’t need any changes.

The only thing we recommend customizing is email alerts, which can be found in the ‘Alerts’ tab of the settings page.

Customizing your website's security alerts

By default, you will receive a lot of email alerts that can clutter your inbox.

We recommend enabling alerts only for key actions you wish to be notified about, such as plugin changes and new user registrations.

Customizing your WordPress security notifications

This WordPress security plugin is very powerful, so browse through all the tabs and settings to see all that it does such as malware scanning, audit logs, failed login attempt tracking, and more.

For more information, you can see our detailed Sucuri review.

Enable a Web Application Firewall (WAF)

The easiest way to protect your site and be confident about your WordPress security is by using a web application firewall (WAF).

A website firewall blocks all malicious traffic before it even reaches your website.

  • A DNS-level website firewall routes your website traffic through its cloud proxy servers. This allows it to send only genuine traffic to your web server.
  • An application-level firewall examines the traffic once it reaches your server but before loading most WordPress scripts. This method is not as efficient as the DNS-level firewall in reducing the server load.

To learn more, see our list of the best WordPress firewall plugins.

How website firewall blocks attacks

We used Sucuri on WPBeginner for many years and still recommend it as one of the best web application firewalls for WordPress. We recently switched from Sucuri to Cloudflare because we needed a larger CDN network with features that focused more on enterprise clients.

You can read about how Sucuri helped us block 450,000 WordPress attacks in a month.

Attacks blocked by Sucuri

The best part about Sucuri’s firewall is that it also comes with a malware cleanup and blacklist removal guarantee. That means that if you were to be hacked under their watch, they guarantee to fix your website, no matter how many pages you have.

This is a pretty strong warranty because repairing hacked websites is expensive. Security experts normally charge more than $250 per hour, while you can get the entire Sucuri security stack for $199 for a whole year.

Improve Your WordPress Security With the Sucuri Firewall

That being said, Sucuri is not the only DNS-level firewall provider out there. The other popular competitor is Cloudflare. See our comparison of Sucuri vs. Cloudflare (Pros and Cons).

Move Your WordPress Site to SSL/HTTPS

SSL (Secure Sockets Layer) is a protocol that encrypts data transfer between your website and the user’s browser. This encryption makes it harder for someone to sniff around and steal information.

How SSL Works

Once you enable SSL, your website address will use HTTPS instead of HTTP. You will also see a padlock or similar icon sign next to your website address in the browser.

SSL certificates are typically issued by certificate authorities, and their prices start from $80 to hundreds of dollars each year. Due to added cost, most website owners in the past opted to keep using the insecure protocol.

To fix this, a non-profit organization called Let’s Encrypt decided to offer free SSL Certificates to website owners. Their project is supported by Google Chrome, Facebook, Mozilla, and many more companies.

It’s easier than ever to start using SSL for all your WordPress websites. Many hosting companies now offer a free SSL certificate for your WordPress website.

If your hosting company does not offer one, then you can purchase an SSL certificate from Domain.com. They have the best and most reliable SSL deals on the market. The certificate comes with a $10,000 security warranty and a TrustLogo security seal.

If you do everything that we have mentioned thus far, then you are in pretty good shape.

But as always, there’s more that you can do to harden your WordPress security.

Keep in mind that some of these steps may require coding knowledge.

Change the Default Admin Username

In the old days, the default WordPress admin username was ‘admin’. Since usernames make up half of the login credentials, this made it easier for hackers to do brute-force attacks.

Thankfully, WordPress has since changed this and now requires you to select a custom username at the time of installing WordPress.

However, some 1-click WordPress installers still set the default admin username to ‘admin’. If you notice that to be the case, then it’s probably a good idea to switch your web hosting.

Since WordPress doesn’t allow you to change usernames by default, there are three methods you can use to change the username.

  1. Create a new admin username and delete the old one.
  2. Use the Username Changer plugin
  3. Update username from phpMyAdmin

We have covered all three of these in our detailed guide on how to properly change your WordPress username.

Note: Just to be clear, we are talking about changing the username called ‘admin’, not the administrator user role, which is also sometimes called ‘admin’.

Disable File Editing

WordPress comes with a built-in code editor that allows you to edit your theme and plugin files right from your WordPress admin area.

In the wrong hands, this feature can be a security risk, which is why we recommend turning it off.

Adding custom CSS in a child theme's stylesheet in the theme file editor

You can easily do this by adding the following code to your wp-config.php file or with a code snippet plugin like WPCode (recommended):

We show you how to do this step by step in our guide on how to disable theme and plugin editors from the WordPress admin panel.

Alternatively, you can do this with 1-click using the Hardening feature in the free Sucuri plugin mentioned above.

[Back to Top ↑]

Disable PHP File Execution in Certain WordPress Directories

Another way to harden your WordPress security is by disabling PHP file execution in directories where it’s not needed, such as /wp-content/uploads/.

You can do this by opening a text editor like Notepad and pasting this code:

Next, you need to save this file as .htaccess and upload it to the /wp-content/uploads/ folder on your website using an FTP client.

For a more detailed explanation, see our guide on how to disable PHP execution in certain WordPress directories.

Alternatively, you can do this with 1-click using the Hardening feature in the free Sucuri plugin that we mentioned above.

Limit Login Attempts

By default, WordPress allows users to try to log in as many times as they want. This leaves your WordPress site vulnerable to brute-force attacks. This is where hackers try to crack passwords by trying to log in with different combinations.

This can be easily fixed by limiting the failed login attempts a user can make. If you are using the web application firewall mentioned earlier, then this is automatically taken care of.

However, if you don’t have the firewall set up, then you can go ahead using the steps below.

First, you need to install and activate the free Limit Login Attempts Reloaded plugin. For more details, see our step-by-step guide on how to install a WordPress plugin.

Upon activation, the plugin will start to limit the number of login attempts users can take.

The default settings will work for most websites, however, you can customize them by visiting the Settings » Limit Login Attempts page and clicking the ‘Settings’ tab at the top. For example, to comply with GDPR laws, you can click the ‘GDPR compliance’ checkbox.

Limit Login Attempts

For detailed instructions, take a look at our guide on how and why you should limit login attempts in WordPress.

Add Two Factor Authentication (2FA)

The two-factor authentication method requires 2 different steps for users to log in:

  1. The first step is the username and password.
  2. The second step requires you to use a code from a device or app in your possession that hackers can’t access, such as your smartphone.

Most top online websites like Google, Facebook, and Twitter, allow you to enable it for your accounts. You can also add the same functionality to your WordPress site.

First, you need to install and activate the WP 2FA – Two-factor Authentication plugin. For more details, see our step-by-step guide on how to install a WordPress plugin.

A user-friendly wizard will help you set up the plugin and then you will be given a QR code.

Use Your Authenticator App to Scan the QR Code

You will need to scan the QR code using an authenticator app on your phone, such as Google Authenticator, Authy, and LastPass Authenticator.

We recommend using LastPass Authenticator or Authy because they allow you to back up your accounts to the cloud. This is very useful in case your phone is lost, reset, or you buy a new phone. All your account logins will be easily restored.

Most of these apps work in a similar way, and if you are using Authy, then you simply click the ‘+’ or ‘Add account’ button in the authenticator app.

Click the + Button to Add an Account

This will let you scan the QR code on your computer using your phone’s camera. You may first need to give the app permission to access the camera.

After giving the account a name, you can save it.

Next time you log in to your website, you will be asked for the two-factor authentication code after you enter your password.

Users Must Enter an Authentication Code Before Logging In

Simply open the authenticator app on your phone, and you will see a one-time code.

You can then enter the code on your website to finish logging in.

Find Your 2FA Token

Change the WordPress Database Prefix

By default, WordPress uses wp_ as the prefix for all tables in your WordPress database.

If your WordPress site is using the default database prefix, then it makes it easier for hackers to guess what your table name is. This is why we recommend changing it.

You can change your database prefix by following our step-by-step tutorial on how to change the WordPress database prefix to improve security.

Note: Changing the database prefix can break your site if it’s not done properly. Only do this if you feel comfortable with your coding skills.

[Back to Top ↑]

Password Protect WordPress Admin and Login Page

Password protect WordPress admin example

Normally, hackers can request your wp-admin folder and login page without any restrictions. This allows them to try their hacking tricks or run DDoS attacks.

You can add additional password protection on a server-side level, which will effectively block those requests.

Just follow our step-by-step instructions on how to password-protect your WordPress admin (wp-admin) directory.

Disable Directory Indexing and Browsing

Directory Browsing

When you type the address of one of your website folders into a web browser, you will be shown the web page called index.html if it exists. If it doesn’t exist, then you will be shown a list of files in that folder instead. This is known as directory browsing.

Directory browsing can be used by hackers to find out if you have any files with known vulnerabilities, so they can take advantage of these files to gain access.

Directory browsing can also be used by other people to look into your files, copy images, find out your directory structure, and other information. This is why it is highly recommended that you turn off directory indexing and browsing.

You need to connect to your website using FTP or your hosting provider’s file manager. Next, locate the .htaccess file in your website’s root directory. If you cannot see it there, then refer to our guide on why you can’t see the .htaccess file in WordPress.

After that, you need to add the following line at the end of the .htaccess file:

Options -Indexes

Don’t forget to save and upload the .htaccess file back to your site.

For more on this topic, see our article on how to disable directory browsing in WordPress.

Disable XML-RPC in WordPress

XML-RPC is a core WordPress API that helps connect your WordPress site with web and mobile apps. It has been enabled by default since WordPress 3.5.

However, because of its powerful nature, XML-RPC can significantly amplify brute-force attacks.

For example, if a hacker traditionally wanted to try 500 different passwords on your website, then they would have to make 500 separate login attempts. This can be caught and blocked by the Limit Login Attempts Reloaded plugin.

But with XML-RPC, a hacker can use the system.multicall function to try thousands of passwords with say 20 or 50 requests.

This is why if you are not using XML-RPC, then we recommend that you disable it.

There are 3 ways to disable XML-RPC in WordPress, and we have covered all of them in our step-by-step tutorial on how to disable XML-RPC in WordPress.

Tip: The .htaccess method is the best one because it’s the least resource-intensive. The other methods are easier for beginners.

Alternatively, this is taken care of automatically if you are using a web application firewall (WAF) as we mentioned earlier.

Automatically Log Out Idle Users in WordPress

Logged-in users can sometimes wander away from the screen, and this poses a security risk. Someone can hijack their session, change passwords, or make changes to their account.

This is why many banking and financial sites automatically log out an inactive user. You can set up similar functionality on your WordPress site as well.

You will need to install and activate the Inactive Logout plugin. Upon activation, visit the Settings » Inactive Logout page to customize the logout settings.

Logout idle users

Simply set the time duration and add a logout message. Then, don’t forget to click on the ‘Save Changes’ button at the bottom of the page to store your settings.

For step-by-step instructions, please refer to our guide on how to automatically log out idle users in WordPress.

Add Security Questions to the WordPress Login Screen

Adding a security question to your WordPress login screen makes it even harder for someone to get unauthorized access.

You can add security questions by installing the Two Factor Authentication plugin. Upon activation, you need to visit the Multi-factor Authentication » Two Factor page to configure the plugin’s settings.

This will allow you to add various types of two-factor authentication to your site, including security questions.

Adding Security Questions to WordPress Login

For more detailed instructions, see our tutorial on how to add security questions to the WordPress login screen.

Scan WordPress for Malware and Vulnerabilities

Malware Scan

If you have a WordPress security plugin installed, then it will routinely check for malware and signs of security breaches.

However, if you see a sudden drop in website traffic or search rankings, then you may want to scan for malware manually. You can do this using your WordPress security plugin or one of the best malware and security scanners.

Running these online scans is quite straightforward. You just enter your website URL, and their crawlers go through your website to look for known malware and malicious code.

Now, keep in mind that most WordPress security scanners can only warn you if your site contains malware. They can’t remove the malware or clean a hacked WordPress site.

This brings us to the next section, cleaning up malware and hacked WordPress sites.

Fix a Hacked WordPress Site

Many WordPress users don’t realize the importance of backups and website security until their website is hacked.

Hackers install backdoors on affected sites, and if these backdoors are not fixed properly, then your website will likely get hacked again.

For the adventurous and DIY users, we have compiled a step-by-step guide on fixing a hacked WordPress site.

However, cleaning up a WordPress site can be very difficult and time-consuming. Our advice would be to let a professional take care of it.

If you are paying to use the Sucuri security plugin we mentioned above, then hacked site repair is built into the price.

You can also use the WPBeginner Pro Services hacked site repair service. This requires a one-time payment of $249 and includes premium file determination, malicious code removal, software and security updates, and a cleaned site backup.

WPBeginner Pro Services Hacked Site Repair

We guarantee to fix your site or give your money back. We also cover your website for 30 days after the repair, so if you get hacked again during that time, we’ll be there to fix it.

We have been cleaning and securing WordPress websites for 10+ years, so you’ll have peace of mind when you use our Hacked Site Repair service.

Bonus Tip: Hire a WordPress Maintenance Service

As a busy small business owner, you may not have time to monitor your website security and protect it from vulnerabilities. So, to ease your mind and lighten your workload, you can hire a WordPress maintenance service for 24/7 security monitoring.

WPBeginner Pro Services offers comprehensive WordPress website maintenance at an affordable price. It includes security monitoring, routine cloud backups, WordPress updates, uptime monitoring, and much more.

WPBeginner WordPress website maintenance service

Simply choose a monthly maintenance service package that suits your needs, and you’ll get a more secure WordPress site and extra free time to work on other aspects of your business.

If you’d like other recommendations, you can see our picks of the best website maintenance services for WordPress.

We hope this article helped you learn the best practices for WordPress security and discover the top WordPress security plugins for your website. You may also want to see our ultimate WordPress SEO guide to improve your SEO rankings, and our expert tips on how to speed up WordPress.

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

Lượt xem: 17

Trả lời

Email của bạn sẽ không được hiển thị công khai. Các trường bắt buộc được đánh dấu *