WordPress:修改自动生成文件所有者/用户组权限问题求助
Hey there, let’s tackle this WordPress permission headache you’re dealing with—this is a super common pain point when web server users and FTP groups don’t align, so you’re definitely not alone here. Let’s break down the problem and walk through actionable fixes.
1. First, Let’s Understand the Root Issue
When your host auto-deployed WordPress, the system created all files with www-data as both the owner and group—that’s the user/group your web server runs under. Your FTP account is part of the users-ftp group, so you don’t have the necessary read/write access to modify those files. On top of that, some plugins (especially cache tools) need to write to specific directories, and misaligned permissions can block those operations too.
2. Quick Win: Add Your FTP User to the www-data Group
The simplest fix is to give your FTP user shared access to the www-data group. Run this command via SSH (ask your host for SSH access if you don’t have it):
sudo usermod -aG www-data your-ftp-username
- The
-aGflag adds your user to the group without removing them from existing groups. - You’ll need to log out of your FTP session and log back in for the group change to take effect.
3. Tune File/Directory Permissions for Dual Access
If adding your user to the group isn’t enough, adjust the permissions so both www-data and your FTP group can interact with files safely:
- Set directories to
775(read/write/execute for owner and group, read/execute for others):find /path/to/your/wordpress-root -type d -exec chmod 775 {} \; - Set files to
664(read/write for owner and group, read-only for others):find /path/to/your/wordpress-root -type f -exec chmod 664 {} \; - Finally, ensure all files/directories have
www-dataas the group owner:sudo chown -R www-data:www-data /path/to/your/wordpress-root
4. Fix Plugin & Cache-Specific Glitches
If your cache plugin or plugin manager is still acting up:
- For cache tools: Locate their cache directory (usually in
wp-content/cache) and manually set its permissions to775—this lets the web server write cache files and you clear them via FTP if needed. - For plugin installations: Double-check that the
wp-content/pluginsandwp-content/uploadsdirectories have the775permission andwww-datagroup ownership. This removes the "permission denied" errors when installing/updating plugins via WordPress admin.
5. Why Your Host Might Have Dropped the Ball
Hosts often stick to default permission setups for security reasons—adding users to www-data or adjusting permissions can feel risky if they don’t know your specific use case. But as long as your FTP account is secured with a strong password and only given to trusted team members, these fixes are safe for most business websites.
内容的提问来源于stack exchange,提问作者Eric Weichhart

