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 withPermission denied; WordPress cannot update or install. - Too permissive under suEXEC. A
0777directory 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
- 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 showrootor the old UID after a restore or manual upload. - 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. - 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. - Tighten anything at 0777 — replace world-writable modes; suEXEC/suPHP refuse to execute them and they are a security hole. Scripts go to
0644(or0755only if they must be executable as CGI). Never leave0777as a “fix” — it is often the cause of the refusal, not the cure. - Special files that legitimately need write — apps like WordPress write to
wp-content/uploads/and sometimeswp-content/. With the correct owner (the cPanel user) and0755directories /0644files, the account can write there already — you do not need0777.wp-config.phpcan even be tightened to0600since only the account reads it. - 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.
- 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.