If your PHP or WordPress app is having problems creating or writing to files or directories, the problem is almost always incorrect file ownership.

All of your app's files should be owned by the app's system user. Most likely, you've created files for your app while SSH'd in as root or SFTP'd files to your app using root. Because PHP does not run as root, it can't write to those files or directories.

Correcting File and Directory Ownership

This is serious stuff!
Be very, very careful running the command below. If you type or copy-and-paste this command incorrectly, you could mess up your entire server beyond repair!

To correct the file ownership for all of the apps belonging to the default sellcloud system user, log in to your server as root and run the following command:

sudo chown -R sellcloud:sellcloud /srv/users/sellcloud/apps

If you are having permissions problems with apps belonging to other system users, replace sellcloud in the command above with the name of the system user.

Examples of Errors Indicating File Permission Problems

The following are some of the errors you may receive for file permission problems.

Warning: copy(/srv/users/sellcloud/apps/wordpress/wp-admin/menu.php)
    [function.copy]: failed to open stream: Permission denied in
    /srv/users/sellcloud/apps/wordpress/wp-admin/includes/class-wp-filesystem-direct.php on line 122
Could not copy file: /srv/users/sellcloud/apps/wordpress/wp-admin/includes/wp-rdf.php
Downloading update from https://downloads.wordpress.org/release/wordpress-3.9.zip…
Unpacking the update…
Could not create directory.
Downloading update from http://wordpress.org/extend/themes/download/responsive.3.4.6.zip.
Unpacking the update.
Installing the latest version.
Enabling Maintenance mode.
Removing the old version of the theme.
Could not create directory. /srv/users/sellcloud/apps/wordpress/wp-content/themes/responsive/
Theme upgrade Failed.
Warning: move_uploaded_file(images/robot.jpg): failed to open stream:
    Permission denied in /srv/users/sellcloud/apps/myapp/process.php on line 78
JFolder::create: Could not create directoryPath: /srv/users/sellcloud/apps/joomla/
Warning: Failed to move file!
ErrorException: Warning: mkdir(): Permission denied in
    /srv/users/sellcloud/apps/symfony/Symfony/Component/HttpKernel/Profiler/FileProfilerStorage.php line 42

at ErrorHandler->handle('2', 'mkdir(): Permission denied', '/srv/users/sellcloud/apps/Symfony/vendor/
symfony/symfony/src/Symfony/
Component/HttpKernel/Profiler/FileProfilerStorage.php', 
'42', array('dsn' => 'file:/home/howard/
Symfony/app/cache/dev/profiler'))
Warning: Your Magento folder does not have sufficient write permissions.
ErrorException: Warning: file_put_contents(
    /srv/users/sellcloud/apps/laravel-develop/app/config/../storage/meta/services.json):
    failed to open stream: Permission denied in
    /srv/users/sellcloud/apps/laravel-develop/vendor/laravel/framework
/src/Illuminate/Filesystem/Filesystem.php line 77
Alert: For Control Panel Help & Tutorials, click here: Panel Tutorials
Was this answer helpful? 0 Users Found This Useful (0 Votes)