This guide helps cPanel server admins and WordPress site owners fix plugin, theme and update installs that fail from the WordPress dashboard. You click Install or Update and get “Installation failed: Could not create directory.”, “Destination folder already exists.” or “Could not copy file.” Sometimes a form titled “Connection Information” asks for FTP (File Transfer Protocol) details instead. On cPanel, all four usually come from files owned by the wrong user, a full disk or inode quota, or a folder left by an earlier failed install. Fix the ownership so the cPanel account user owns the whole site, clear any leftover folder, and check the quota. By the end, a test plugin installs cleanly and WordPress stops asking for FTP details.
What you’ll accomplish
- Match each error message to the step of the install that failed.
- Check who owns the site files and which user PHP runs as.
- Restore the correct owner and permissions without breaking the cPanel layout of
public_html. - Find a full disk or inode quota and clear leftover folders from failed installs.
- Prove the fix with a test install from the command line and from the dashboard.
Prerequisites
You need root SSH access to the server for the ownership fix. A cPanel user can run the checks, but only root can change a file back from root to the account user. WHM alone is not enough.
The steps assume a current cPanel and WHM server with EasyApache 4, where PHP runs as the account user. That is the case with the PHP-FPM, suPHP, CGI and LSAPI handlers (the modules that run PHP for the web server). The older DSO handler runs PHP as the nobody user, and the ownership fix below does not apply to it. Step 2 shows you how to check.
WP-CLI, the WordPress command-line tool, makes testing much faster. Many cPanel servers have it at /usr/local/bin/wp. Check with which wp. The commands use cpuser as the account name and /home/cpuser/public_html as the site folder. Replace both with your own.
Back up the account, or at least public_html, before you change ownership in bulk.
How it works
When you install or update a plugin from the dashboard, WordPress first picks a write method. It calls a function named get_filesystem_method(). If the constant FS_METHOD is set in wp-config.php, WordPress uses that value. Otherwise it writes a small test file named temp-write-test-… in wp-content. It then compares the owner of that test file with the owner of WordPress’s own file wp-admin/includes/file.php.
If the two owners match, WordPress uses the direct method and writes files itself through PHP. If they differ, or the test file cannot be written at all, it falls back to FTP or SSH. That is when the “Connection Information” form appears. Its text starts with “To perform the requested action, WordPress needs to access your web server.”
Once it has a write method, the install runs in four steps. WordPress downloads the ZIP file to a temporary folder. It unpacks it into a working folder under wp-content/upgrade/. It checks that wp-content/plugins/<name>/ does not exist yet. Finally it moves the unpacked copy into wp-content/plugins/. Themes follow the same path into wp-content/themes/. Each step writes to disk as the PHP user, so each one can fail on ownership or quota. The diagram shows which error comes from which step.
On cPanel, the usual trigger is a manual action done as root. Someone restored a backup, extracted a ZIP, moved a site or ran WP-CLI as root. The new files end up owned by root, and PHP, running as cpuser, can no longer write next to them.
Step-by-step
1. Check who owns the site files. Compare the owner of the main folders with the account user.
id cpuser
ls -ld /home/cpuser/public_html /home/cpuser/public_html/wp-content /home/cpuser/public_html/wp-content/plugins /home/cpuser/public_html/wp-content/upgrade
stat -c '%U:%G %a %n' /home/cpuser/public_html/wp-admin/includes/file.php
id shows the user and its main group, for example uid=1005(cpuser) gid=1008(cpuser). On a healthy cPanel site, public_html itself shows cpuser nobody with mode drwxr-x--- (750). Everything inside it shows cpuser cpuser. If you see root or nobody as the owner of wp-content, plugins or file.php, you have found the cause.
If wp-content/upgrade does not exist, that is fine. WordPress creates it when it can. List every file with a wrong owner to see how far the problem goes.
find /home/cpuser/public_html ! -user cpuser -ls | head -20
No output means every file belongs to cpuser.
2. Confirm PHP runs as the account user. The ownership fix only works if PHP runs as cpuser. Check the handler for each PHP version.
/usr/local/cpanel/bin/rebuild_phpconf --current
You will see lines such as ea-php82 SAPI: fpm. Any handler other than dso runs PHP as the account user. If the site’s PHP version uses dso, stop here and read the last section of this guide first.
3. Ask WordPress which write method it picks. Run this as the account user, not as root, so it tests the same user PHP uses.
cd /home/cpuser/public_html
sudo -u cpuser -- wp eval 'require_once ABSPATH . "wp-admin/includes/file.php"; echo get_filesystem_method(), PHP_EOL;'
The answer direct means the ownership test passes. ftpext or ftpsockets means it fails, which is why the dashboard asks for FTP details. If sudo is not installed, use su -s /bin/bash cpuser -c '<command>' instead.
Also check that FS_METHOD is not forcing a value.
grep -n "FS_METHOD" /home/cpuser/public_html/wp-config.php
No output means WordPress detects the method itself, which is what you want on cPanel.
4. Check the disk and inode quota. A full quota gives “Could not copy file.” or “Could not create directory.” even when ownership is right. An inode is the entry a filesystem uses to track one file, and cPanel plans often cap them.
quota -s cpuser
df -h /home
df -i /home
In the quota output, compare the used space with the quota and limit columns under both blocks and files. A value at or above the limit, or a * next to it, means the account is full. df shows the whole filesystem. Use% at 95% or more there is a server problem, not only an account problem. In cPanel, the Disk Usage page shows the same numbers for the account. Our guide to cPanel disk quotas for space and inodes explains how to raise a limit or find what fills it.
5. Restore the correct owner. As root, give the whole site back to the account user. Then put the cPanel layout of public_html itself back.
chown -R cpuser:cpuser /home/cpuser/public_html
chown cpuser:nobody /home/cpuser/public_html
chmod 750 /home/cpuser/public_html
The first command fixes everything inside the site. public_html must stay owned by cpuser with the group nobody and mode 750, so the web server can enter it while other accounts cannot. If you leave it as cpuser:cpuser, the site can return “403 Forbidden” errors. No output from these commands means they worked. Our guide on fixing WordPress file ownership after a manual move covers addon domains and other document roots.
6. Reset the permissions. Folders should be 755 and files 644. Keep wp-config.php tighter, because it holds the database password.
find /home/cpuser/public_html -mindepth 1 -type d -exec chmod 755 {} +
find /home/cpuser/public_html -type f -exec chmod 644 {} +
chmod 600 /home/cpuser/public_html/wp-config.php
The -mindepth 1 flag skips public_html itself, so it keeps its 750 mode. Mode 600 on wp-config.php works because PHP reads it as cpuser. Then make sure the working folder exists and belongs to the account user.
sudo -u cpuser mkdir -p /home/cpuser/public_html/wp-content/upgrade
ls -ld /home/cpuser/public_html/wp-content/upgrade
Expect drwxr-xr-x ... cpuser cpuser ... upgrade.
7. Clear leftovers from the failed install. “Destination folder already exists.” means a folder with the plugin’s name is already in wp-content/plugins/. First check whether WordPress knows it as an installed plugin.
sudo -u cpuser -- wp plugin list --fields=name,status,version
ls -la /home/cpuser/public_html/wp-content/plugins/
If the folder appears in ls but not in wp plugin list, it is a broken leftover. Move it aside rather than deleting it, so you can go back.
mv /home/cpuser/public_html/wp-content/plugins/plugin-name /home/cpuser/plugin-name.leftover
If the plugin is listed and you want to replace it with a ZIP you uploaded, WordPress 5.5 and later offer a “Replace current with uploaded” button on the upload screen. With WP-CLI, wp plugin install plugin.zip --force does the same. Finally, empty the working folder, which often holds half-unpacked copies.
ls -la /home/cpuser/public_html/wp-content/upgrade/
rm -rf /home/cpuser/public_html/wp-content/upgrade/*
It only holds temporary copies, so emptying it is safe while no install runs.
Validate it works
Run the ownership test again as the account user.
cd /home/cpuser/public_html
sudo -u cpuser -- wp eval 'require_once ABSPATH . "wp-admin/includes/file.php"; echo get_filesystem_method(), PHP_EOL;'
It should now print direct. Next, install and activate a small test plugin.
sudo -u cpuser -- wp plugin install hello-dolly --activate
A good result ends with Plugin 'hello-dolly' activated. and Success: Installed 1 of 1 plugins. Check that the new files belong to the account user.
ls -ld /home/cpuser/public_html/wp-content/plugins/hello-dolly
Expect cpuser cpuser. Now repeat the install that failed from the dashboard. It should finish without asking for FTP details. Then remove the test plugin.
sudo -u cpuser -- wp plugin uninstall hello-dolly --deactivate
Troubleshooting
Files turn back into root-owned files a day later. Something keeps writing as root. The usual culprits are a cron job in root’s crontab that runs wp, or an admin who runs WP-CLI as root with --allow-root. Run WP-CLI as the account user with sudo -u cpuser -- wp, and move site cron jobs into the account’s own crontab.
The site shows “Briefly unavailable for scheduled maintenance.” A failed update left the .maintenance file in the site root. Remove it with rm /home/cpuser/public_html/.maintenance. Then run the update again.
“Download failed. Destination directory for file streaming does not exist or is not writable.” The temporary folder PHP uses for downloads is not writable. A tight open_basedir setting, which limits the folders PHP may open, is a common reason. Create a folder the account owns, such as /home/cpuser/tmp. Then add define( 'WP_TEMP_DIR', '/home/cpuser/tmp' ); to wp-config.php above the line that says to stop editing.
Someone added define( 'FS_METHOD', 'direct' ); and the error changed. With that constant, WordPress skips the ownership test. You then get “Could not create directory.” instead of the FTP form. The constant hides the cause rather than fixing it. Once ownership is right, remove the line and let WordPress detect direct itself.
Everything looks right but installs still fail. Look at the PHP error log for the site, usually /home/cpuser/public_html/error_log, right after a failed install. On CloudLinux servers, also open Resource Usage in cPanel. An account at its limit for processes or inodes can fail in the middle of an unpack. The official WordPress advanced administration handbook covers file permissions and wp-config.php constants in more depth.
When this is the wrong approach
If the server runs PHP with the DSO handler, PHP runs as nobody. Giving files to cpuser will then make them unwritable for PHP, and the only way to write would be to open the folders to everyone. Switch the PHP version to PHP-FPM in MultiPHP Manager instead. That handler runs PHP as the account user and is safer on a shared server.
If the files belong to a different cPanel account, for example after a site was copied between accounts, do not only change the owner. Check that the site is in the right account and that its database user belongs to that account too.
If the site is in the middle of a security incident, such as unknown PHP files or changed core files, stop first. Changing ownership in bulk can hide how an attacker got in. Clean and investigate before you repair permissions.
Finally, some sites set DISALLOW_FILE_MODS in wp-config.php on purpose, so that changes only go through a deploy process. That constant hides the install and update buttons. Leave it in place and install through the deploy process instead.
Running WordPress that earns real money deserves an operator — Stack Harbor runs that stack under Enterprise WordPress; book an infrastructure consult.