Skip to content
WordPress and WooCommerce5 min read

How to secure a WordPress site

Short answer

WordPress security starts with three habits: keep core, plugins and themes updated, give every admin a strong password plus two-factor authentication, and keep regular backups. Then close the common entry points: the built-in file editor, PHP execution inside the uploads folder, and xmlrpc.php if you don't use it.

ArabyHost teamLast updated: ShareWhatsAppXLinkedIn
Contents
  1. Before you start
  2. Steps to secure WordPress
  3. Troubleshooting
  4. On ArabyHost

WordPress core is rarely the way in. Sites get compromised through a plugin or theme nobody updated for months, a reused password that leaked somewhere else, or a forgotten file left on the server. The steps below go from most to least important, and most of them take a single sitting.

Before you start

  • An Administrator account in WordPress.
  • Access to cPanel or its File Manager so you can edit wp-config.php and .htaccess.
  • A fresh backup before changing anything (see WordPress backup and restore).

Steps to secure WordPress

1. Update everything and delete what you don’t use

Go to Dashboard > Updates and update WordPress, plugins and themes. Then on the Plugins page delete deactivated plugins you don’t need: a deactivated plugin’s files are still on the server and its vulnerabilities can still be exploited. Keep one default theme alongside your active theme and remove the rest.

Turn on Enable auto-updates next to plugins you trust. Never install “nulled” copies of paid plugins or themes; they are one of the most common sources of malware.

2. Strong passwords and non-obvious usernames

  • Don’t use the username admin. Create a new administrator under Users > Add New User, log in with it, then delete the old account and attribute its content to the new one.
  • Give every admin a long random password; the password generator creates one in a click.
  • Review the user list and give editors and authors the lowest role that lets them do their job.

3. Turn on two-factor authentication

Two-factor authentication stops a stolen password from being enough. Install a plugin such as Two Factor or Wordfence Login Security, or use the 2FA built into the security plugin you already run, and pair it with an authenticator app. Store the backup codes somewhere outside the site.

4. Limit login attempts

Brute-force attacks try thousands of passwords against wp-login.php. Use a plugin that limits attempts and temporarily blocks an address after several failures. If your host already runs a server-level firewall such as Imunify360, stick to one security plugin so rules don’t clash and lock out real visitors.

5. Disable the built-in file editor

Add this line to wp-config.php, above /* That's all, stop editing! */:

define( 'DISALLOW_FILE_EDIT', true );

It removes the theme and plugin editors from the dashboard, so someone who steals an admin login can’t paste PHP straight into your site from a browser.

6. Set correct file permissions

On most hosts the right values are 755 for directories, 644 for files, and 600 or 640 for wp-config.php. Never use 777. Change permissions in cPanel under File Manager > Permissions, or over SSH:

cd ~/public_html
find . -type d -exec chmod 755 {} \;
find . -type f -exec chmod 644 {} \;
chmod 600 wp-config.php

7. Block PHP execution in uploads

An attacker who manages to upload a file usually tries to run it from wp-content/uploads. Create an .htaccess file inside that folder containing:

<FilesMatch "\.(php|phtml|phar)$">
  Require all denied
</FilesMatch>

Images and documents keep working; any PHP file placed there simply won’t run.

8. Protect wp-config.php and close xmlrpc.php if unused

In the main .htaccess inside public_html, add this above the # BEGIN WordPress block:

<Files wp-config.php>
  Require all denied
</Files>
<Files xmlrpc.php>
  Require all denied
</Files>
Options -Indexes

Careful: the WordPress mobile app and some Jetpack features need xmlrpc.php, so leave it open if you use them. Options -Indexes stops the server from listing the contents of folders that have no index file.

9. Force HTTPS and rotate the security keys

Serve the site only over HTTPS with a valid SSL certificate (see how to force HTTPS). If you suspect someone got in, replace AUTH_KEY and the other keys in wp-config.php with fresh values from the official generator; every logged-in session ends immediately:

https://api.wordpress.org/secret-key/1.1/salt/

10. Hide errors and run a supported PHP version

On a live site WP_DEBUG must be false so paths and error messages aren’t shown to visitors. Use a PHP version that still gets security fixes, such as 8.1 or newer, and test the site after switching.

11. Keep off-site backups

Backups are the plan for when everything else fails. Keep at least a daily backup, plus an extra copy on your computer or external storage before any major update.

Troubleshooting

  • Locked out after enabling a security plugin or 2FA: in File Manager, rename the plugin’s folder in wp-content/plugins (for example wordfence to wordfence-off). WordPress disables it and you can log in normally; then rename it back and reconfigure.
  • 403 or 500 error after editing .htaccess: remove the last block you added and reload. One typo is enough to break the site. If a 403 appears only when saving a post or form, a firewall rule may be the cause; see ModSecurity 403.
  • The security plugin blocks you: add your own IP address to its allowlist, or wait for the temporary block to expire.
  • You see signs of a hack: don’t just delete the suspicious file; attackers usually leave more than one backdoor. Follow the hacked site clean-up guide and change the WordPress, database and cPanel passwords.

On ArabyHost

Every ArabyHost account runs isolated in CloudLinux CageFS with its own resource limits (LVE), so other accounts on the server can’t see your files. Imunify360 adds server-level security, a free SSL certificate is issued automatically (AutoSSL / Let’s Encrypt), and JetBackup takes daily backups you can restore from cPanel. WordPress hosting plans include one-click WordPress install and LiteSpeed Cache. If something breaks after these changes, the Araby AI assistant in the panel reads the error log and explains the cause and the fix.

FAQ

Is one security plugin enough to secure WordPress?

No. A plugin helps block login attacks and scan files, but most hacks come from an outdated plugin or theme or a weak password. Updates, two-factor authentication and backups matter more than any plugin.

Should I change the wp-login.php URL?

Moving the login page cuts down automated noise, but it isn't real protection on its own. Strong passwords, two-factor authentication and login attempt limits do the actual work.

How do I know if my WordPress site is hacked?

Common signs are visitors being redirected to strange sites, spam pages showing up in Google, admin users you don't recognise, or new PHP files inside the uploads folder. If you see any of these, clean the site and change every password.

Useful? Share it with someone who needs it:WhatsAppXLinkedIn

Read next

Ready to put your idea online?

Fast, isolated hosting, support that understands you, and an AI assistant that fixes problems with you.