A secure, CLI-based utility for restoring and fixing WordPress file and directory permissions.
This script automatically ensures your WordPress installation uses the correct permission structure:
- Directories →
755 - Files →
644 wp-config.php→600
It includes safety checks, dry-run preview mode, ownership correction (--chown), and smart exclusion for .git, node_modules, and other non-core directories.
✅ Safely fixes all WordPress file & directory permissions
✅ Compatible with Linux, macOS, and shared hosting
✅ Optional dry-run mode (--dry-run)
✅ Optional ownership correction (--chown=user:group)
✅ Protects against symbolic link issues
✅ Displays a full summary report and timing
✅ Cross-platform safe (POSIX + Windows support)
Place the script in the root directory of your WordPress installation:
/var/www/html/
├── wp-admin/
├── wp-content/
├── wp-includes/
├── wp-config.php
└── wp-permission-fixer.php
php wp-permission-fixer.php --dry-runphp wp-permission-fixer.phpsudo php wp-permission-fixer.php --chown=www-data:www-data| Type | Path | Mode |
|---|---|---|
| WordPress Directories | /wp-content, /wp-admin, /wp-includes |
755 |
| WordPress Files | All .php, .js, .css, etc. |
644 |
| Configuration | /wp-config.php |
600 |
| .htaccess | Root .htaccess |
644 |
🔧 Starting WordPress permission fixer
📁 Root: /var/www/html
🧪 Dry-run mode enabled (no actual changes)
📊 Summary
🗂️ Directories fixed: 24
📄 Files fixed: 157
🚫 Skipped: 12
⚠️ Errors: 0
⏱️ Time: 0.81s
✅ Permissions successfully fixed.
Directories: 755 | Files: 644 | wp-config.php: 600
💡 Delete this script after use for better security.
| Flag | Description |
|---|---|
--dry-run |
Preview what changes would be made, without modifying anything |
--chown=user:group |
Set ownership recursively (e.g., --chown=www-data:www-data) |
- Never run this script outside a WordPress root directory.
- Always back up your site before changing permissions.
- Delete this file after running it on production servers.
- Works best under CLI mode, not through a browser.
Seyyed Ali Mohammadiyeh (Max Base) 📍 Senior Software Engineer, Researcher, and Craftsman 🌐 GitHub: BaseMax
MIT License
Pull requests are welcome! If you find a bug or want to suggest an enhancement, feel free to open an issue.
Made with 💻 & 🛠️ by Max Base “Secure WordPress, the right way.”