Skip to content
Back to Blog
WordPress10 min read

WordPress File Permissions: Production Best Practices for 2026

Learn the correct file permission model for production WordPress sites, why common shortcuts break security, and how to implement a permissions scheme that balances safety with functionality.

Written by Abdul AbrorTechnical Hosting Support Engineer
WordPress File Permissions: Production Best Practices for 2026
On this page

Most WordPress security guides hand you a one-liner that recursively sets every file to 644 and every directory to 755, then call it a day. That advice ignores how your web server runs, who owns the files, and what happens when WordPress tries to update itself. Production environments deserve better.

This guide covers the permission model that works in real hosting environments, the anti-patterns that create security holes or break functionality, and the rationale behind each decision.

Why File Permissions Matter

File permissions control three things: who can read a file, who can modify it, and who can execute it. In a WordPress context, you have three actors:

  • The web server process (Apache, Nginx, LiteSpeed) that serves pages and runs PHP
  • The PHP process that executes your WordPress code
  • Your SSH/SFTP user that deploys code and manages files

When permissions are wrong, one of three things happens: the site breaks because WordPress cannot read its own files, the site becomes vulnerable because the web server can write to core files, or you lock yourself out of managing the installation.

The Permission Model for Production

A secure production setup separates ownership from execution. Your user account owns the files. The web server reads them but cannot modify core WordPress files or plugins. WordPress can write only to specific directories where uploads and caches belong.

File Ownership

All WordPress files should be owned by your user account, not by the web server user (www-data, apache, nobody). This matters because if the web server owns the files, a PHP vulnerability can silently overwrite core WordPress files or inject malicious code into plugins.

chown -R yourusername:yourusername /path/to/wordpress

In cPanel environments, this is typically your cPanel username for both user and group. On a VPS, your deploy user should own the files.

Directory Permissions

Set directories to 755 (rwxr-xr-x). This allows your user to create and delete files inside, while the web server can read and traverse the directory structure.

find /path/to/wordpress -type d -exec chmod 755 {} \;

Never use 777. It grants write access to everyone, including any compromised process running on the server. The "I'll fix it later" 777 typically stays forever and becomes your breach point.

File Permissions

Set files to 644 (rw-r--r--). Your user can edit them, the web server can read them, but nothing can execute them as binaries.

find /path/to/wordpress -type f -exec chmod 644 {} \;

The web server does not need write access to .php files. PHP files are read by the web server and interpreted, not executed as binaries. The execute bit on a PHP file does nothing useful and creates confusion.

wp-config.php Special Case

Your wp-config.php holds database credentials and authentication salts. Restrict it to 640 or even 600.

chmod 600 /path/to/wordpress/wp-config.php

This prevents other users on shared hosting from reading your database password. Some guides suggest 400 (read-only even for you), but that makes emergency edits awkward. 600 is the practical middle ground.

Writable Directories

WordPress needs write access to three locations: wp-content/uploads, wp-content/cache (if used), and potentially wp-content/upgrade during updates.

Instead of making these world-writable, configure your PHP handler correctly:

PHP-FPM or suPHP: When PHP runs as your user, the default 755 and 644 permissions already work. WordPress writes files as your user, so no special permissions are needed.

mod_php or CGI with different user: If PHP runs as www-data but files are owned by your user, add your user to the web server group and use group-writable permissions:

chown -R yourusername:www-data /path/to/wordpress/wp-content/uploads
chmod -R 775 /path/to/wordpress/wp-content/uploads
find /path/to/wordpress/wp-content/uploads -type f -exec chmod 664 {} \;

This pattern grants write access to both your user and the web server group without opening permissions to everyone.

Anti-Patterns to Avoid

Setting Everything to 777

The most dangerous shortcut. 777 (rwxrwxrwx) grants write access to everyone. On shared hosting, this means another compromised account can modify your files. On a VPS, any service running on the machine can write to your WordPress directory.

The "upload folder won't work" panic leads people here. The real fix is aligning file ownership with the PHP process user, not opening the permissions floodgates.

Chowning Everything to www-data

Making the web server user own all files seems logical until you realize this hands full control of your codebase to every PHP script. A single vulnerable plugin can now overwrite wp-config.php, inject backdoors into themes, or replace core files with compromised versions.

WordPress updates break this model anyway—when you update via SFTP, your user writes files owned by you, not www-data, creating a mixed ownership mess.

Ignoring the .htaccess Execute Bit

Your .htaccess file should be 644, never executable. It is read by Apache as a configuration file, not executed. Setting it to 744 or 755 signals confusion about how Apache works and provides no benefit.

Recursive Permissions on wp-content

Running a blanket chmod -R 777 wp-content to fix an upload issue also makes every plugin and theme writable. Narrow the scope—only the uploads directory needs write access, and only if PHP runs as a different user.

Setting Files to 444

Some hardening guides suggest making all WordPress core files read-only (444) to prevent modification. This breaks WordPress updates and plugin installations. You will be forced to manually change permissions every time you update, which means you will either stop updating (worse security) or automate permission changes (defeating the purpose).

Read-only core files make sense in containerized or immutable deployments where updates happen via redeployment, not in traditional hosting.

The PHP Handler Matters

Your permission strategy depends entirely on how your server runs PHP. Check with:

ps aux | grep php

Look at the user column.

suPHP/PHP-FPM as your user: PHP scripts run as you. WordPress writes files owned by you. Standard 755/644 works everywhere. This is the cleanest model and the one most quality hosts use.

mod_php as www-data: PHP runs as the web server user. You need group-writable permissions for uploads, or WordPress cannot write files. Use the 775/664 pattern on wp-content/uploads and ensure your user is in the www-data group.

CGI/FastCGI as nobody: The worst scenario. nobody owns nothing, so you are forced to make upload directories world-writable or change ownership entirely. If your host runs this model, push them to upgrade to PHP-FPM or switch hosts.

Automated Updates and Permissions

WordPress automatic updates require write access to the WordPress directory during the update process. If you allow automatic updates in production (debatable), WordPress must be able to write to core files, plugins, and themes.

The secure approach:

  1. Disable automatic updates in production with define('AUTOMATIC_UPDATER_DISABLED', true); in wp-config.php.
  2. Test updates in staging with correct ownership and permissions.
  3. Deploy updated code via Git, rsync, or your deployment pipeline.
  4. Keep tight 644/755 permissions with your user owning everything.

The convenience approach for smaller sites:

  1. Run PHP as your user via PHP-FPM.
  2. Keep 755/644 permissions.
  3. Allow WordPress to update itself; it writes files as your user, so ownership stays clean.

Never compromise by making everything 777 just to enable automatic updates. That cure is worse than the disease.

Special Files and Directories

.htaccess and nginx.conf

Apache .htaccess files should be 644 and owned by your user. WordPress sometimes writes to .htaccess (for permalinks), so if PHP runs as a different user, you need group-write (664) or you manually update rewrite rules.

Nginx does not use .htaccess. Your nginx.conf or site configuration file lives outside the web root and should be 644, owned by root or your deploy user, writable only via your deployment process.

wp-content/upgrade

WordPress creates this directory during updates. If it does not exist, WordPress tries to create it. Either pre-create it with appropriate permissions or ensure the wp-content directory itself is group-writable if PHP runs as www-data.

mkdir -p /path/to/wordpress/wp-content/upgrade
chown yourusername:www-data /path/to/wordpress/wp-content/upgrade
chmod 775 /path/to/wordpress/wp-content/upgrade

wp-content/cache

Caching plugins write here. Same rules as uploads—writable by the PHP process user. If you use object caching (Redis, Memcached), this directory might not be used at all.

Verification Checklist

After setting permissions, verify your configuration:

# Check ownership
ls -la /path/to/wordpress/ | head -20

# Confirm wp-config.php is not world-readable
ls -l /path/to/wordpress/wp-config.php

# Test upload functionality
# Upload a test image via WordPress admin

# Verify no files are world-writable
find /path/to/wordpress -type f -perm -002

# Verify no directories are world-writable except intentional caches
find /path/to/wordpress -type d -perm -002

If the last two commands return anything outside of /tmp or intentional cache directories, tighten those permissions.

When to Break the Rules

Development environments can relax permissions for convenience. Setting everything to 777 on your local laptop where you are the only user is harmless. Just never carry that habit into production.

Shared hosting with poorly configured suEXEC or no PHP-FPM sometimes forces compromises. If your host requires 777 on uploads, document it as technical debt and plan your migration to a competent host.

Conclusion

WordPress file permissions are not arbitrary numbers to copy from Stack Overflow. They encode a security model: your user owns the code, the web server reads it, and write access is granted only where WordPress must store uploads or caches.

Production environments should never use 777 permissions or hand ownership to the web server user. The correct scheme depends on your PHP handler—most modern hosts run PHP-FPM as your user, making the standard 755/644 pattern both secure and functional.

Verify your setup, test uploads, and resist the temptation to loosen permissions when something breaks. The real fix is aligning your PHP execution model with your ownership structure, not opening security holes. Your future self—and your clients—will thank you.

FAQ

What permissions should I use for a new WordPress installation?

Directories: 755, files: 644, wp-config.php: 600. Ensure your user owns all files. If uploads fail, check your PHP handler—do not jump straight to 777.

Why can't WordPress update plugins automatically?

Either the plugin directory is not writable by the PHP process user, or you disabled automatic updates in wp-config.php. If PHP runs as your user and you own the files, 755/644 permissions should allow updates.

Should I make wp-config.php executable?

No. PHP files are interpreted by the PHP engine, not executed as binaries. The execute bit is irrelevant and should remain unset (644 or 600).

Is 755 on directories safe?

755 (rwxr-xr-x) is the standard secure permission for directories. It allows the owner to modify contents and everyone else to read and traverse. This is correct for web directories.

What if I run WordPress in a Docker container?

Containers typically run the web server and PHP process as the same user. Set ownership to match that user (often www-data inside the container) and use 755/644. If mounting volumes from the host, ensure UIDs align or use a bind mount with correct user mapping.

How do I fix mixed ownership after a bad migration?

Recursively reset ownership to your user: chown -R yourusername:yourusername /path/to/wordpress. Then apply the standard permission scheme: directories to 755, files to 644, and wp-config.php to 600.