Skip to content

Fixing WordPress file ownership after a manual move on cPanel

How to fix WordPress file ownership and permissions on cPanel after a manual file move that left some files owned by root or another user — the cPanel-aware chown/chmod sequence.

After SFTP-ing a WordPress site between accounts, restoring a backup as root, or extracting an archive from someone else’s hand-off, file ownership is often wrong. WordPress can read the files (the web server runs as the cPanel user, which can read most permissions) but it can’t write them — uploads fail, plugins won’t update, and the admin reports “could not create directory” on every operation.

What’s happening

On a cPanel server, every account has its own user (typically the cPanel username) and group. The web server runs PHP as that user (in suPHP, FCGI, or PHP-FPM with per-user pools). When a file is owned by another user — root after an unzip run by root, or nobody:nobody from a misconfigured upload — PHP running as the cPanel user can’t write to it. Read might still work (depending on the world-readable bit), which is why the site appears to work but updates and uploads fail.

How to verify

id
whoami
ls -la ~/public_html/ | head -20
ls -la ~/public_html/wp-content/uploads/ | head
find ~/public_html ! -user $USER -ls 2>/dev/null | head
find ~/public_html ! -group $USER -ls 2>/dev/null | head

find ... ! -user $USER lists every file not owned by the cPanel user. If you see anything owned by root, nobody, or another cPanel user, that’s the problem.

The fix

  1. As root (you need root for this — the cPanel user can’t chown to itself if it doesn’t own the file), reclaim ownership:

    chown -R cpaneluser:cpaneluser /home/cpaneluser/public_html/

    That sets every file under public_html to the cPanel user and group. Do it once after a manual move, then never as root again.

  2. Set directory permissions to 755 and file permissions to 644:

    find /home/cpaneluser/public_html -type d -exec chmod 755 {} \;
    find /home/cpaneluser/public_html -type f -exec chmod 644 {} \;
  3. Tighten wp-config.php to 600 — it has DB credentials and salts:

    chmod 600 /home/cpaneluser/public_html/wp-config.php
  4. .htaccess stays 644 — Apache and LiteSpeed need to read it, and WordPress needs to be able to rewrite it when permalinks change:

    chmod 644 /home/cpaneluser/public_html/.htaccess
  5. wp-content/uploads/ needs to be writable by the cPanel user. 755 is fine; some operators go 775 to give the group write access, but on cPanel that doesn’t gain you anything because the group is the cPanel user’s own group:

    chmod -R 755 /home/cpaneluser/public_html/wp-content/uploads/
  6. After fixing, verify by trying an operation that needs write access:

    wp plugin install hello-dolly --activate
    wp plugin delete hello-dolly

    If those succeed, ownership and permissions are correct.

  7. Avoid the next occurrence. When extracting archives, do it as the cPanel user, not root:

    su - cpaneluser
    cd ~/public_html
    tar -xzf ~/backup.tar.gz

    When restoring backups via WHM, the restore process sets ownership correctly. When using JetBackup, the same. Manual archive extraction is the typical source of broken ownership.

For environments where account moves and restores happen routinely, Stack Harbor handles them as part of cPanel server administration.

Stack Harbor operates production WordPress at scale — see enterprise WordPress support for the managed model, or book a WordPress consult for a written read of your current shape.