Must read Filesystem permissions troubleshoot

Status
Not open for further replies.

Rodolfo

Chevereto Developer
Chevereto Staff
Joined
Oct 7, 2008
Messages
15,519
Points
237
Location
Chevereto HQ
Website
rodolfoberrios.com
Chevereto is a system that works over PHP and to put it in context PHP can run as module, separated process, as a child-process, etc. In other words, it can run in many ways. PHP usually runs by Apache (or any webserver like nginx, litespeed, lighttpd, etc.) and depending on how you are running PHP you could have issues with permissions that will cause upload issues.

In computers, folders have ownership and if you don't have the ownership to read/write that folder you will have issues. PHP is indeed something that runs with the permission mask of a given user, so in some cases you will have conflicts, most usual is when you login your server using FTP or SSH and you create or upload folders as root user but PHP is not running as root. In those cases is impossible to fix the permission mask by PHP because it doesn't have the authority over the conflicting files or folder.

Root owned files and how-to fix it

Lets say that your PHP (Apache or Nginx) runs as "www-data" user but your FTP login is "root". Everything that you upload using that root FTP login will be owned by root, not www-data which means that PHP won't have write permission over that file or folder.

If you access using your root FTP access and you create a folder "system" into var/www/content/images you will notice that the owner/group is not the same as the owner/group from a folder created by the script. For example, /var/www/content/images/system is owned by root/root but Apache is running as www-data user. This means that PHP (Chevereto) won't be able to touch anything in this folder owned by root. You will get a "Can't move file" or "permission error" issues. This applies to any folder and file in the system.

Fixing conflicting root permissions
  1. Login to your server using SSH
  2. Go to your Chevereto's root folder (for example /var/www/)
  3. Execute the following commands where "www-data" is the user who runs Apache or Nginx:
Code:
sudo chown www-data:www-data * -R
sudo usermod -a -G www-data root
Please note that this must be done using SSH by an user with root privileges otherwise it won't work.
 
Status
Not open for further replies.