Skip to content

Wrong file permissions and ownership on cPanel: what breaks and how to reset

Uploads, plugin installs, or page saves fail with permission errors after a manual upload or restore. Here is how to read ownership and modes and set them back to sane values.

When a cPanel site suddenly cannot write a file, install a plugin, save an upload, or even serve a page — with Permission denied, a 403, or a silent failure — the cause is almost always file ownership or mode that no longer matches what cPanel expects. A manual upload as root, an extracted archive, a restore, or a careless chmod 777 leaves files the account’s PHP and Apache processes cannot read or write. The fix is to understand the small set of correct values on a cPanel server and reset everything to them, rather than loosening permissions until something works.

What’s happening

On a cPanel server every account runs its web and PHP processes as that account’s own user (suEXEC, suPHP, or a per-user PHP-FPM pool). That design means files must be owned by the cPanel user and carry sane modes: directories 0755, files 0644, and scripts no looser than 0755. Two failure shapes follow from breaking this:

  • Too restrictive or wrong owner. Files owned by root, nobody, or the old account UID — typical after unzipping or restoring as root — cannot be read or written by the account’s processes. Apache returns 403; PHP writes fail with Permission denied; WordPress cannot update or install.
  • Too permissive under suEXEC. A 0777 directory or a group-/world-writable script is rejected by suEXEC and suPHP as a security measure, so “open it up to 777” frequently makes things worse, not better, and is also a real security exposure.

The reason the same symptom (a failed write or a 403) maps to both extremes is that cPanel’s per-user execution model cares about who owns the file and whether the mode is in a safe band — not simply whether the bits are “open.”

How to verify

Read ownership and mode on the affected path, and walk the full directory chain.

# Ownership + mode of the docroot and the failing path
ls -la /home/<cpaneluser>/public_html/ | head
ls -la /home/<cpaneluser>/public_html/wp-content/

# Walk every parent — one bad directory blocks everything below
namei -l /home/<cpaneluser>/public_html/wp-content/uploads/

# The error log states the exact permission failure
tail -30 /home/<cpaneluser>/logs/<domain>.error.log
#   (13)Permission denied: ...

Find files with the wrong owner or dangerous modes across the account.

# Anything NOT owned by the cPanel user (the usual culprit)
find /home/<cpaneluser>/public_html ! -user <cpaneluser> -o ! -group <cpaneluser>

# World-writable files and dirs suEXEC will reject
find /home/<cpaneluser>/public_html -perm -0002 -ls | head
find /home/<cpaneluser>/public_html -type f -perm 0777

Confirm the account’s PHP handler (suEXEC behaviour depends on it):

grep -i "<domain>" /etc/userdatadomains

The fix

  1. Reset ownership to the cPanel user — the highest-yield fix. WHM does it safely: Account Functions » Reset Account Permissions sets ownership and baseline modes for the account in one pass. From the shell: chown -R <cpaneluser>:<cpaneluser> /home/<cpaneluser>. Run this first whenever files show root or the old UID after a restore or manual upload.
  2. Set directories to 0755 — find /home/<cpaneluser>/public_html -type d -exec chmod 755 {} \;. A directory missing its execute/traverse bit blocks access to everything inside it, producing 403s that look like a content problem.
  3. Set files to 0644 — find /home/<cpaneluser>/public_html -type f -exec chmod 644 {} \;. Readable by the server, writable by the owner. This is the correct default for HTML, PHP, images, and config.
  4. Tighten anything at 0777 — replace world-writable modes; suEXEC/suPHP refuse to execute them and they are a security hole. Scripts go to 0644 (or 0755 only if they must be executable as CGI). Never leave 0777 as a “fix” — it is often the cause of the refusal, not the cure.
  5. Special files that legitimately need write — apps like WordPress write to wp-content/uploads/ and sometimes wp-content/. With the correct owner (the cPanel user) and 0755 directories / 0644 files, the account can write there already — you do not need 0777. wp-config.php can even be tightened to 0600 since only the account reads it.
  6. Fix the source, not just the symptom — if permissions keep reverting, find why: an upload done over SFTP as a different user, a cron running as root, or a backup restored by hand. Correct the process (upload as the cPanel user, run crons under the account) so you are not resetting permissions weekly.
  7. Confirm the handler matches the owner — a PHP-FPM pool running as the wrong user will fail even with correct file ownership. Check the pool user in WHM » MultiPHP Manager; it must be the account owner.

Once ownership is the cPanel user and modes sit at 0755/0644, retry the action that failed — a successful upload or plugin install plus a clean error log is the proof, far better than a 0777 that happens to let one write through while leaving the account exposed. Stack Harbor handles cPanel permission and ownership remediation under cPanel/WHM management — start a conversation.