Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

Fix WordPress File Ownership for Safe Plugin Updates

· 7 min read · Home Tech

In this article
  1. Why File Ownership Breaks Plugin Updates
  2. How WordPress Checks Permissions
  3. Step-by-Step Fix Using SSH
  4. When You Don't Have SSH Access
  5. Common Mistakes and How to Avoid Them
  6. Security Considerations
  7. Alternatives to Changing Ownership
  8. Frequently Asked Questions

WordPress plugin updates fail or trigger a prompt for FTP credentials when the web server cannot write to the plugin files—this is almost always a file ownership or permissions problem. The safe fix is to set the files to be owned by your system user (or a dedicated service account) and the group to the web server's group, then adjust permissions to 644 for files and 755 for directories. Below is the full background, the exact commands, and the common pitfalls to avoid.

Why File Ownership Breaks Plugin Updates

WordPress runs as PHP under a web server such as Apache, Nginx, or LiteSpeed. When you upload a plugin through the admin dashboard, the web server creates the files, so those files are owned by the web server's user (often www-data, nginx, or apache). When you later try to update that plugin, WordPress again needs to write to the same directory. If the directory is owned by a different user (for example, your FTP account user), the web server may not have write permission, and WordPress will fall back to asking for FTP credentials—or the update will fail entirely.

Another common scenario is when you upload files via SSH or SFTP as your system user, but the group is not set to the web server's group. Even if the user owns the files, the web server needs group write access to modify them. The goal is to give the web server just enough access to update files without making everything world-writable, which would be a security risk.

How WordPress Checks Permissions

WordPress uses the FS_METHOD constant to decide how to write files. If it is set to direct, WordPress attempts to write directly to the filesystem. If that fails, it falls back to FTP or SSH. The check is simple: PHP's is_writable() function is called on the directory. If it returns true, direct writes are used; otherwise, you see the FTP credentials screen.

This means you need the web server user to have write permission on the wp-content directory and everything below it. The most reliable way is to make the web server user the owner, but that can conflict with your own SFTP access. The recommended compromise is to set the group to the web server's group and give the group write permission, while keeping the owner as your own user.

Step-by-Step Fix Using SSH

If you have SSH access to your server, this is the cleanest method. You will need to know your web server's user and group. Common pairs are www-data for both on Debian/Ubuntu, nginx for both on RHEL-based systems, and apache for both on older CentOS. Run these commands from the root of your WordPress installation:

  1. Find your current user with whoami (e.g., alice).
  2. Set the owner to your user and the group to the web server group:
    sudo chown -R alice:www-data /var/www/html
  3. Set directory permissions to 755 (owner read/write/execute, group read/execute, others read/execute):
    sudo find /var/www/html -type d -exec chmod 755 {} \;
  4. Set file permissions to 644 (owner read/write, group read, others read):
    sudo find /var/www/html -type f -exec chmod 644 {} \;
  5. Give the group write permission on wp-content so WordPress can update plugins and themes:
    sudo chown -R alice:www-data wp-content
    sudo chmod -R 775 wp-content

After this, log out and back in, then try updating a plugin. If it still asks for FTP, add this to your wp-config.php file to force direct writes:

define('FS_METHOD', 'direct');

This tells WordPress to always attempt direct writes, bypassing the FTP prompt.

When You Don't Have SSH Access

If you are on shared hosting, you may not have SSH. In that case, you can often fix ownership through your hosting control panel's file manager. Look for a "Permissions" or "CHMOD" option. Set directories to 755 and files to 644, and ensure the owner is your account user. However, if the web server runs as a different user (like nobody), you might not be able to change the group. In that scenario, the hosting provider usually has a tool to reset permissions, or you can contact support to adjust the group.

Another option on shared hosting is to use an FTP client to change permissions. Connect via FTP, right-click the wp-content folder, and set permissions to 755 for directories and 644 for files. This does not change ownership, but if the group is already the web server's group, it may be enough. If not, you may need to ask your host to set the group correctly.

Common Mistakes and How to Avoid Them

  • Setting everything to 777—this makes files world-writable, which is a severe security risk. Never use 777 on a live site.
  • Changing ownership of the entire server—only change ownership within your WordPress directory, not the whole filesystem.
  • Forgetting the group—even if the owner is correct, the web server may not be in the owner group. Always set the group to the web server's group.
  • Using the wrong web server user—check with ps aux | grep nginx or ps aux | grep apache to see the exact user.
  • Not applying changes recursively—use -R with chown and find with chmod to cover all subdirectories.

Security Considerations

Giving the web server write access to wp-content is necessary for updates, but it also means that if your site is compromised, the attacker can modify plugin files. To mitigate this, you can:

  • Use a security plugin that monitors file integrity.
  • Disable file editing in the admin dashboard by adding define('DISALLOW_FILE_EDIT', true); to wp-config.php.
  • Regularly back up your site so you can restore if something goes wrong.

It is also wise to remove write permissions after updates are done. Some administrators set wp-content to 755 during updates and then back to 555 (read/execute only) for normal operation. This is safer but requires SSH access each time you update.

Alternatives to Changing Ownership

If you cannot change ownership, you can update plugins via SFTP or SSH manually. Download the new plugin zip, upload it to the server, and replace the old folder. This bypasses the need for the web server to write files, but it is more work. Another alternative is to use a staging site where you can test updates, then push changes to production with a deployment tool like Git or a plugin like Duplicator.

Some managed WordPress hosts (like WP Engine or Kinsta) handle file ownership for you, so you never see this issue. If you are on a VPS or dedicated server, the ownership fix is the standard solution.

Frequently Asked Questions

Why does WordPress ask for FTP credentials even after I changed permissions?

This usually means the web server still cannot write to the directory. Check that the group is correct and that the FS_METHOD is set to direct. Also verify that SELinux (on RHEL-based systems) is not blocking writes—you may need to set the correct SELinux context for the web server.

What is the difference between ownership and permissions?

Ownership defines which user and group a file belongs to. Permissions define what the owner, group, and others can do (read, write, execute). WordPress needs both: the web server must be either the owner or in the group, and the permissions must allow write for that user or group.

Can I use 777 permissions temporarily to update a plugin?

It is not recommended, even temporarily. 777 allows any user on the server to write to the files, which is a security risk. If you must, use 775 (owner and group write) instead, and change it back immediately after the update.

How do I find out which user the web server runs as?

Run ps aux | grep -E 'apache|nginx|httpd' in SSH. The first column of the output shows the user. Alternatively, create a PHP file with <?php echo exec('whoami'); ?> and load it in your browser.

Will changing ownership affect my ability to upload files via SFTP?

No, as long as you keep the owner as your own user. You will still be able to read and write files via SFTP because you own them. The group setting only affects the web server's access.

What if I accidentally change ownership of the entire server?

This can break your server. If it happens, you need to restore the original ownership. Without a backup, you may need to reinstall the operating system or use a recovery tool. Always limit chown to your WordPress directory.