In almost every hacked WordPress site I’ve investigated, the attacker changed files. They added a backdoor in the uploads folder, modified index.php, injected code into a theme’s functions.php or dropped a new file with a random name in the site root. The changes were there to be found. Nobody was looking.
File integrity monitoring is the practice of watching your site’s files and alerting you when they change unexpectedly. It doesn’t prevent attacks, but it shortens the time between compromise and discovery from months to minutes. That difference often decides whether an incident is a quick cleanup or a long, expensive recovery.
Here’s how I set it up on WordPress sites, from simple options anyone can use to server-level monitoring.
Why file changes are such a good signal
On a well-run WordPress site, files change in predictable ways:
- When you update WordPress core, plugins or themes.
- When editors upload media, which only affects the uploads folder.
- When caching plugins write cache files.
- When you deploy code changes.
Anything outside those patterns is suspicious. A PHP file appearing in uploads, a core file changing when no update happened, or a theme file modified at three in the morning are all worth investigating.
That predictability is what makes file monitoring effective. You’re not trying to recognise every piece of malware. You’re just noticing that something changed when nothing should have.
Level 1: Verify core and plugin files against checksums
WordPress.org publishes checksums for every version of core and for plugins hosted in the repository. WP-CLI can compare your files against them:
Any file that has been modified, or any extra file in core directories, is reported. This is the quickest way to check whether core or repository plugins have been tampered with.
Limitations to keep in mind:
- Premium plugins and custom themes don’t have public checksums.
- The uploads folder isn’t covered.
- It’s a point-in-time check, not continuous monitoring.
You can schedule it, though. A simple cron job can run the checks daily and email you if anything fails:
| if echo "$OUT" | grep -qi "warning | error | doesn't verify"; then |
|---|---|---|---|
| echo "$OUT" | mail -s "Checksum alert: example.com" [email protected] |
Test the script manually first, because the exact output varies between versions, and make sure your server can send mail reliably.
Level 2: Security plugins with file monitoring
Many WordPress security plugins include file change detection. They scan files periodically, compare them with a known baseline or official versions and alert you to differences. This is the easiest option for site owners without server access.
The trade-offs:
- Scans run inside WordPress, using PHP and your hosting resources. On large sites, full scans can be heavy.
- If an attacker gains full control of the site, they can potentially tamper with the plugin itself.
- Scan frequency is often limited by hosting resources or the plugin’s plan.
Still, a plugin-based scanner is far better than nothing, and for many small sites it’s the right choice.
Level 3: Server-level integrity monitoring
On servers you control, dedicated tools give stronger, more efficient monitoring. They run outside WordPress, so a compromised site can’t easily disable them.
AIDE
AIDE, the Advanced Intrusion Detection Environment, builds a database of file attributes and hashes, then compares the current state against it. It’s available in most Linux distributions.
A simplified configuration for a WordPress site might watch PHP and configuration files while ignoring cache and upload changes:
| !/var/www/example.com/wp-content/uploads/.*.(jpg | jpeg | png | gif | webp | avif | pdf)$</code> |
|---|
Initialise the database, then run checks on a schedule:
After legitimate changes, such as updates, you update the baseline so the next check compares against the new known-good state.
inotify-based watchers
Tools built on Linux’s inotify system can watch files in real time and trigger alerts immediately when something changes. This is useful for high-value sites where you want to know within seconds that a PHP file appeared in uploads.
Host-provided monitoring
Some managed hosts include malware scanning and file monitoring. Find out exactly what they monitor and how they alert you, rather than assuming.
What to monitor and what to ignore
The biggest problem with file monitoring is noise. If you get fifty alerts a day for legitimate changes, you’ll start ignoring them, and then you’ll miss the one that matters.
Always monitor:
- WordPress core files.
- Plugin and theme PHP files.
- wp-config.php and .htaccess files.
- Any PHP file in uploads, which should never exist.
- New files in the site root.
Usually exclude or treat separately:
- Cache directories.
- Log files.
- Normal media uploads.
- Temporary files from backup plugins.
A good compromise for uploads is to ignore images and documents but alert on any executable file type, such as .php, .phtml or .phar.
Handling legitimate changes
Updates and deployments will always change files. You need a process so these don’t drown out real alerts:
- Update the baseline after planned changes. After updating plugins or deploying code, refresh the monitoring baseline.
- Schedule updates. If updates happen at known times, alerts outside those times stand out.
- Use version control for custom code. If your theme and custom plugins live in Git, you can compare server files with the repository. Any difference that isn’t in Git is suspicious.
If this shows changes nobody committed, someone modified files directly on the server.
Responding to an alert
When an alert arrives, don’t panic and don’t delete the file immediately.
- Check whether the change was planned. Was there an update, a deployment or a plugin installation?
- Look at the file. Is it obfuscated? Does it contain eval, base64_decode or code that fetches remote content?
- Check the timestamp against access logs to see which requests happened just before.
- Look for related changes. Attackers rarely change just one file.
- If it’s malicious, treat it as an incident. Preserve evidence, find the entry point, clean thoroughly and rotate credentials.
Having a short written response plan means you don’t have to think it through under pressure.
Combine monitoring with other signals
File monitoring works best alongside:
- Activity logs, showing logins, user changes and plugin installations.
- Uptime monitoring, which catches outages caused by broken or malicious code.
- Search Console alerts, which catch SEO spam and security issues.
- Outgoing email monitoring, which reveals spam-sending scripts.
Together, these give you a clear picture: who logged in, what changed, and what effect it had.
A practical setup for different situations
Small brochure site on shared hosting: a reputable security plugin with file change alerts, plus Search Console monitoring.
Business site on a VPS: daily WP-CLI checksum checks via cron, AIDE or a similar tool for server-level monitoring, and an activity log plugin.
WooCommerce store or high-value site: real-time monitoring of PHP files, Git-based comparison for custom code, external monitoring of checkout page scripts and alerts sent to a channel someone checks every day.
Don’t forget the database
Files are only half of a WordPress site. Some infections inject scripts into posts or options without touching a single file, and file monitoring alone won’t see them. Pair your file checks with a simple database routine. Watch for new administrator accounts, changes to critical options such as siteurl, home and admin_email, and unexpected script tags in content. An activity log plugin covers the first two. For the last, a periodic search with WP-CLI works well:
Record the normal numbers for your site. If the count of admins jumps from two to three overnight, or script tags suddenly appear in the options table, you have something to investigate.
Keep alerts where people will see them
An alert that lands in an inbox nobody reads is the same as no alert. Decide who receives monitoring alerts and through which channel, whether that’s email, a team chat channel or a phone notification. For client sites, I route alerts to my own monitoring channel rather than the client’s general inbox, because I’m the one who can act on them. Test the alerting path occasionally by making a harmless change, such as creating a test file, and confirming the alert arrives.
Frequently asked questions
Will file monitoring slow down my site?
Server-level tools run outside WordPress and have little impact on visitors if scheduled sensibly. Plugin-based scans can use significant resources on large sites, so schedule them for quiet hours.
How often should scans run?
Daily is a good minimum. For stores and high-value sites, hourly checks or real-time monitoring of critical paths are worth it.
Can malware hide from file monitoring?
Some malware lives only in the database, not in files. File monitoring won’t catch that, which is why database checks and activity logs are also important. But most persistent infections involve at least one file change.
What if I get alerts every time I update plugins?
That’s expected. Update the baseline after planned updates, or schedule updates at fixed times so you can tell planned changes from unexpected ones.
Final thoughts
File integrity monitoring is one of the most practical security measures for WordPress. It doesn’t depend on recognising specific malware, it just notices change. Start with checksum verification, add a scanner or server tool that suits your setup, tune out the noise and decide in advance how you’ll respond to alerts. The goal is simple: when something changes that shouldn’t, you’re the first to know.




