WordPress

WordPress File Permissions by Host Type (With the Exact Commands)

By , Lead SEO & Co-founder 7 min read
A secure file vault at night with rows of small drawers, each with a three-light lock panel in cyan, one drawer's lock glowing crimson, a laptop on a cart connected to the panel and cables neatly routed along the floor

WordPress file permissions are usually quoted as one rule, folders 755 and files 644, but the right numbers depend on a question most guides skip: which server user does PHP run as? On most shared hosting, PHP runs as you, and 755/644 is correct. On a VPS where PHP runs as a separate web user, the same numbers either break updates or quietly let any compromised plugin rewrite your whole site.

So this guide starts with a two-minute test to find out which setup you have, then gives you the numbers and the commands for each one. If you'd rather not run commands on a live server, tell me about your hosting in the questionnaire and I'll reply with a plan and a fixed quote within one business day.

How WordPress file permissions actually work

Every file and folder on a Linux server has an owner, a group, and three sets of permissions: one for the owner, one for the group, one for everyone else. Each set is a number from 0 to 7, built from read (4), write (2) and execute (1). For a folder, "execute" means "allowed to open it".

So 644 on a file means:

  • 6 for the owner: read and write
  • 4 for the group: read only
  • 4 for everyone else: read only

And 755 on a folder means the owner can do everything, while the group and everyone else can open it and list it but can't add files.

The catch: "owner" is whoever owns the file, and PHP can only write where its own user has write permission. If PHP runs as the owner, 644 lets WordPress update itself. If PHP runs as someone else, 644 makes the file read-only to WordPress.

Step one: find out which user PHP runs as

Two quick checks, no guessing required.

From the WordPress dashboard. Go to Tools > Site Health > Info. The Site Health screen has a "Server" section showing the PHP SAPI (how PHP is connected to the web server), and a "Filesystem Permissions" section showing whether WordPress can write to its main folders. If everything there says "Writable" with 755/644 in place, PHP is almost certainly running as your account user.

From the command line. Upload any image through Media > Add New, then look at who owns the new file:

Terminal
# Shows the owner and group of the newest uploads. Read-only, safe to run anywhere.
# If the owner is your account name, PHP runs as you. If it's www-data, apache or nobody, it doesn't.
ls -l wp-content/uploads/$(date +%Y/%m)/ | tail -3

On a VPS you can also check the running processes:

Terminal
# Lists which users the PHP and web server processes run as. Read-only.
ps -eo user,comm | grep -E "php-fpm|lsphp|httpd|apache2" | sort | uniq -c

WordPress permissions 755 644 by host type

Here's the short version. The details and commands for each row follow.

Host type PHP runs as Folders Files wp-config.php
Shared cPanel, Plesk or LiteSpeed hosting Your account user 755 644 440 or 400
VPS, "locked" mode (updates by command line) Separate web user, e.g. www-data 750 640 440, group = web user
VPS, "dashboard updates" mode Separate web user 775 in wp-content, 750 elsewhere 664 in wp-content, 640 elsewhere 440, group = web user
Managed WordPress hosting Set by the host Don't change Don't change Don't change

Shared hosting: cPanel, Plesk and LiteSpeed

Most shared hosts run PHP as your own account user, through PHP-FPM, suEXEC or LiteSpeed's own PHP handler. That's the setup the WordPress permissions guide has in mind when it says folders should be 755 or 750, files 644 or 640, and wp-config.php 440 or 400 "to prevent other users on the server from reading it."

Open Terminal in cPanel (or SSH in), go to the folder that holds wp-config.php, and run:

Terminal
# Shared hosting where PHP runs as you. Run from the WordPress root folder.
# Resets every folder to 755 and every file to 644, then locks wp-config.php.
# Could break: a plugin that needs to edit wp-config.php later (some caching plugins do).
# If one complains, set wp-config.php to 640 temporarily, let it write, then back to 440.
find . -type d -exec chmod 755 {} +
find . -type f -exec chmod 644 {} +
chmod 440 wp-config.php

No Terminal? cPanel's File Manager can change permissions with right-click > Change Permissions, one item at a time. It works, it's just slow on a site with 20,000 files.

VPS with a separate web user

On a self-managed VPS, PHP often runs as www-data (Ubuntu and Debian) or apache (AlmaLinux and Rocky), while you upload files as your own user. Now you have a real choice, and it's a security choice.

Locked mode. The web user can read everything but write only to uploads (and a cache folder, if you use one). Plugin and core updates happen through WP-CLI (WordPress's command-line tool) as your own user. A hacked plugin can't rewrite your other plugins, because PHP isn't allowed to.

Terminal
# VPS, locked mode. Replace "deploy" with your SSH user and the path with your site.
# Could break: one-click updates and plugin installs in the dashboard (by design).
SITE=/var/www/example.com
sudo chown -R deploy:www-data "$SITE"
sudo find "$SITE" -type d -exec chmod 750 {} +
sudo find "$SITE" -type f -exec chmod 640 {} +
sudo chmod 440 "$SITE/wp-config.php"
# Let PHP write uploads only:
sudo find "$SITE/wp-content/uploads" -type d -exec chmod 770 {} +
sudo find "$SITE/wp-content/uploads" -type f -exec chmod 660 {} +

Pair it with this line in wp-config.php, which the wp-config documentation says blocks plugin and theme installs and updates from the dashboard:

PHP
// Turns off dashboard installs, updates and the file editor. Updates then run via WP-CLI.
define( 'DISALLOW_FILE_MODS', true );

Dashboard updates mode. If your team needs the Update button, give the web user's group write access to wp-content only, and keep core files and wp-config.php read-only to it. It's less strict, but it's honest about the trade-off.

Terminal
# VPS, dashboard-updates mode. Same chown as above, then open up wp-content to the group.
# Could break: nothing. The cost is that a compromised plugin can modify other plugins.
sudo find "$SITE/wp-content" -type d -exec chmod 775 {} +
sudo find "$SITE/wp-content" -type f -exec chmod 664 {} +

Managed WordPress hosting

Managed hosts set ownership and permissions for you, and some reset them automatically. Running chmod -R there tends to cause support tickets rather than prevent hacks. Leave it alone and ask the host if Site Health shows anything unwritable.

Why 777 never fixes anything

When a plugin can't save a file, the forums answer with chmod 777. That means every user on the server, including every other customer on a shared server, can write to that folder. The WordPress docs say plainly that no directories should ever be 777, "even upload directories."

The real problem behind the error is almost always ownership, not permissions. Files copied over by an old FTP account, restored by root, or unzipped by another user end up owned by the wrong person. Fix the owner and 755/644 starts working again.

The same goes for WordPress asking for FTP details when you install a plugin. That prompt means PHP can't write to the folder as its own user. Forcing FS_METHOD to direct in wp-config.php hides the prompt but not the cause.

Permissions after a hack

Permissions are one of the first things I check after a cleanup, because attackers change them on purpose. Two patterns show up again and again:

  • Read-only malware. Infected files set to 444 so a plugin update can't overwrite them. To the owner, the site "updated fine" while the malware stayed.
  • World-writable folders. A 777 folder left behind by a past fix, which lets the next infection land without any password.
Terminal
# Read-only checks after a cleanup. They change nothing.
# 1) Anything writable by every user on the server:
find . -perm -o+w -not -type l
# 2) PHP files set to read-only for everyone (a common malware trick):
find . -type f -name "*.php" -perm 444

If the first command lists anything, reset it with the commands for your host type above. If the second one lists files in plugin folders, compare them to fresh copies before trusting them. That's often how malware keeps coming back after a cleanup that looked complete.

Vlad's take

Permissions are boring, and boring is the goal. Set them once for your host type, fix ownership instead of reaching for 777, and check them again after any migration or restore, because those are the moments they drift.

Permissions also only protect files. They do nothing about a visitor reading wp-config.php through a server misconfiguration or browsing your folders. That's what the Apache 2.4 .htaccess template covers, and the two work best together.

Final thoughts

Run the ownership check first, pick the row in the table that matches your server, and run only the commands for that row. On shared hosting that's three lines. On a VPS, decide between locked mode and dashboard updates before you type anything, because that choice matters more than any single number.

If you want permissions, updates and backups handled every month by someone who checks them, that's part of my WordPress care plan.

WordPress file permissions FAQs

What are the correct WordPress file permissions?

On most shared hosting, folders should be 755, files 644, and wp-config.php 440 or 400. That works because PHP runs as your own account user. On a VPS where PHP runs as a separate web user, use 750 for folders and 640 for files, owned by your user with the web server's group, and give write access only where WordPress truly needs it.

Is 755 or 750 better for WordPress folders?

750 is stricter because it hides folder contents from users who are neither the owner nor in the group. On shared hosting with PHP running as you, both work, and 755 is the safer default because some servers need the web server itself to read folders. On a VPS where the web user is in the group, 750 is the better choice.

Should wp-config.php be 400, 440, 600 or 640?

Use 440 or 400 when PHP runs as the file owner, since only reading is needed. Use 640 when the web server reads it through the group, as on many VPS setups. 600 also works when PHP is the owner. The goal is the same in every case: nobody outside the owner and web server can read the database password.

Why does WordPress ask for FTP credentials to install plugins?

Because PHP can't write to the plugin folder as its own user. Usually the files are owned by a different user than the one PHP runs as. Changing ownership to the PHP user (on shared hosting, your account user) fixes it properly. Setting permissions to 777 or forcing direct file access only hides the problem.

Can wrong file permissions cause a WordPress hack?

They rarely cause the first break-in, which usually comes through an outdated plugin or a stolen password. They decide how far an attacker gets once inside. World-writable folders let malware spread across a site or even across accounts on the same server, and loose wp-config.php permissions can expose the database password to neighbors on shared hosting.

Questions about your own server? Send me the details and I'll tell you which setup you have and what I'd change.

Want a second pair of eyes on your site?

Tell me what's going on in the wordpress maintenance questionnaire. I reply with a plan and a fixed quote within one business day.

Starting at $250/mo Start the questionnaire