Alex Morgan
Alex Morgan
Senior Hosting Analyst
10+ years testing web hosting infrastructure. Benchmarks servers across 4 continents.

如何保护WordPress安全 2026

WordPress powers 43% of the web, which makes it the most targeted platform for hackers. But most attacks are automated, opportunistic, and preventable. They exploit known vulnerabilities in outdated plugins, weak passwords, and default configurations. Securing WordPress properly takes under 2 hours and dramatically reduces your attack surface. These 10 steps, in order of impact, cover the most common attack vectors.

我们如何核对文中步骤

发布前,若步骤依赖主机商,我们会在至少两家平台各走一遍;否则在同一环境隔日执行两次。我们记录控制台报错、不同地区的界面文案差异,并在厂商调整按钮位置后立即更新文案。路径与截图每季度抽检。涉及 DNS、SSL 或付款时,我们确认回滚/补救选项,并链接到官方文档以获取权威表述。

  1. 1

    Step 1: Keep WordPress, themes, and plugins updated

    The single most effective security measure. Over 50% of WordPress hacks exploit vulnerabilities in outdated plugins and themes. Enable automatic updates: Plugins → select all → Bulk Actions → Enable Auto-updates. For WordPress core, in wp-config.php add `define('WP_AUTO_UPDATE_CORE', true);`. Before enabling auto-updates, ensure you have automated backups running so you can revert if an update causes issues.

  2. 2

    Step 2: Use strong passwords and a password manager

    All WordPress accounts should use 20+ character randomly generated passwords. Use a password manager (Bitwarden is free and excellent, 1Password is premium). Never reuse passwords across sites. Change your database password to something complex in wp-config.php and in your hosting control panel. Your wp-config.php database password doesn't change how WordPress logs in. It's a separate credential.

  3. 3

    Step 3: Install a security plugin

    Install Wordfence Security (free tier is comprehensive) or Solid Security (formerly iThemes Security). Enable: malware scanning, login security, brute force protection, and file change detection. Run the initial security audit and fix all flagged issues. Schedule weekly malware scans. These plugins detect many attacks before they cause damage and alert you to suspicious activity.

  4. 4

    Step 4: Enable two-factor authentication (2FA)

    Add 2FA to your WordPress admin login. even if your password is compromised, attackers cannot log in without your phone. Wordfence Security and Solid Security both include 2FA. Alternatively, install WP 2FA plugin. Use an authenticator app (Google Authenticator, Authy) rather than SMS. SMS is vulnerable to SIM-swap attacks.

  5. 5

    Step 5: Change the admin username and limit login attempts

    The username "admin" is targeted by every automated brute-force attack. If your account uses "admin": create a new administrator account with a different username, log in as the new user, delete the old "admin" account (reassign posts to the new user). Then use your security plugin's brute-force protection to lock out IPs after 5 failed login attempts.

  6. 6

    Step 6: Move or hide the wp-admin login page

    Automated bots constantly probe /wp-admin and /wp-login.php. Wordfence and Solid Security can limit login page access to specific IP addresses or add a secret key to the login URL (e.g. yourdomain.com/wp-login.php?secret=yourkey). Alternatively, use a WAF (Cloudflare) to block login page access from all IPs except your office/home IP using firewall rules.

  7. 7

    Step 7: Implement a Web Application Firewall (WAF)

    A WAF filters malicious traffic before it reaches your server. Cloudflare's free plan includes a basic WAF and DDoS protection. Wordfence Security includes a WordPress-specific WAF that blocks known attack patterns. Cloudflare + Wordfence together provide defence in depth. Cloudflare blocks network-level attacks, Wordfence handles application-level attacks.

  8. 8

    Step 8: Disable file editing and PHP execution in uploads

    Two lines in wp-config.php: `define('DISALLOW_FILE_EDIT', true);` removes the theme/plugin code editor from wp-admin (prevents attackers who gain WP access from injecting code). Block PHP execution in uploads folder by adding a .htaccess in wp-content/uploads/: `<Files *.php>` / `deny from all` / `</Files>`. This blocks a common malware injection technique.

  9. 9

    Step 9: Set up automated backups stored off-server

    Backups are your last line of defence if prevention fails. Install UpdraftPlus and configure: daily backups, retention of 7 copies, remote storage to Google Drive or Amazon S3 (off your web server. A compromised server backup is useless). Test restoring from backup at least once so you know the process works before you need it under pressure.

  10. 10

    Step 10: Monitor for changes and scan regularly

    Enable Wordfence's email alerts for: admin account creation, login from unknown location, plugin/theme file changes, and failed login spikes. Sign up for a free uptime monitor (UptimeRobot) to detect any defacement or redirects caused by hacking. Review your hosting account's access logs quarterly for unusual patterns.

1
SiteGround Fastest
Revenue-critical sites are where SiteGround earns the premium: Google Cloud, SuperCacher, and support that actually reads the ticket before replying.
★★★★½
✓ 优点
  • Staging, backups, and PHP version options on SiteGround match our screenshots.
  • High uptime, steady response times on their Google Cloud setup.
  • Staging and daily backups on every plan.
✕ 缺点
  • SiteGround menu labels change. Look for the idea, not one fixed menu path.
  • No free domain included.
月价格$3.99
存储空间10 GB SSD
免费域名✕ 否
在线时间99.99%
2
Hostinger Top Pick
Hostinger has survived multiple yearly cycles on our bench: LiteSpeed, hPanel, and sub-$3 intro pricing still deliver the best overall value for most sites we migrate.
★★★★½
✓ 优点
  • Staging, backups, and PHP version options on Hostinger match our screenshots.
  • Fast LiteSpeed loading, consistent in our repeated tests.
  • Good storage, SSL, and backups on entry plans, no forced add-ons at login.
✕ 缺点
  • Hostinger menu labels change. Look for the idea, not one fixed menu path.
  • No phone support on any plan.
月价格$2.99
存储空间100 GB SSD
免费域名✓ 是
在线时间99.9%

常见问题

How do I know if my WordPress site has been hacked?+
Signs: Google Search Console shows security warnings, your site redirects to spam pages, visitors report malware warnings, Google Analytics shows unusual traffic spikes, or your host sends a malware notification. Run a Wordfence scan immediately and check your hosting file manager for recently modified files.
Is WordPress secure by default?+
WordPress core is secure and regularly patched. Most hacks exploit vulnerable plugins or themes, weak passwords, or outdated installations. not WordPress itself. Keeping everything updated and following this guide's steps makes WordPress very secure.
How much does WordPress security cost?+
The 10 steps in this guide are achievable with free tools (Wordfence free, Cloudflare free, UpdraftPlus free with Google Drive storage). Wordfence Premium ($119/year) adds real-time threat intelligence. Sucuri's website application firewall ($199.99/year) is the most comprehensive paid option.