WordPress Core Upgrade File Ownership for Web Server User
0 reputation · 24 Sept 2022, 08:22 UTC
0 reputation · 24 Sept 2022, 08:22 UTC
WordPress replaces core files during an automatic or manual upgrade using the write access available to the web server process. The goal is to set the correct file owner and group so unattended upgrades can complete without falling back to FTP credentials or leaving a partially replaced file set.
WordPress core does not perform atomic file replacement, and a failed upgrade can leave a `.maintenance` file in the site root alongside mixed file versions. It is unclear whether ownership by the web server user is sufficient, or whether group write access is also required on wp-admin, wp-includes, and the site root for WordPress 6.x.
35775 reputation · 24 Sept 2022, 11:17 UTC
1. What file owner and group should WordPress core directories use for unattended upgrades?
www‑data on Debian/Ubuntu, apache on CentOS).2. Is group write access required in addition to web server user ownership?
3. Does deleting .maintenance before confirming complete file replacement expose a partially upgraded site?
.maintenance prematurely can make the site visible while some files are still being replaced, leading to inconsistent behavior or errors.WordPress upgrades rely on the file‑system permissions of the web‑server user. The core does not perform an atomic replace, so a failed upgrade can leave a mix of old and new files. The .maintenance file is a signal that the upgrade is in progress; it should remain until the process finishes and all files are verified.
.maintenance before the upgrade finishes can expose a partially upgraded site.Identify the web‑server user:
ps aux | grep -E 'apache|httpd|nginx'
# Example output shows the user (e.g., www-data)
Check current ownership of core directories:
ls -ld wp-admin wp-includes wp-content
# Verify that the owner matches the web‑server user
If ownership is incorrect, change it (run as root or using sudo):
sudo chown -R www-data:www-data /path/to/wordpress
# Replace www-data with your web‑server user and group
Confirm that the web‑server user has write permission on the directories:
sudo -u www-data touch /path/to/wordpress/wp-admin/.testwrite
# If the file is created, write permission is present
rm /path/to/wordpress/wp-admin/.testwrite
During an upgrade, keep the .maintenance file in place until the process reports completion. Only delete it manually if you are certain all files have been replaced and verified.
After the upgrade, run a quick check:
wp core check-update --format=json
# Verify that the reported version matches the installed files
To tailor the ownership recommendation precisely, could you confirm the name of the user that your web server runs as on this host?
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.