1

I am running Debian Jessie with pixel. I have a file located at /home/pi/robotAI/static/sqlite/robotAI.sqlite which I need NGINX to access. NGINX runs as www-data and normally when I run the following everything is fine

sudo chown -R pi:www-data /home/pi/robotAI/static/sqlite
sudo chmod -R 777 /home/pi/robotAI/static/sqlite

However for some reason after rebuilding my Pi this approach does not work any more. The problem appears to be that despite granting all permissions as above, the www-data user still cannot access the file. To test this I run the following as the Pi user

ls /home/pi/robotAI/static/sqlite

and I get a display of the content of the folder. However if I run the following command to test as www-data then I get permission denied.

sudo -u www-data ls /home/pi/robotAI/static/sqlite

If I check the permissions on the folder contents using the command below then I get the results shown.

ls -la /home/pi/robotAI/static/sqlite

total 136
drwxrwx--x 2 pi pi         4096 May  6 14:55 .
drwxrwxrwx 3 pi www-data   4096 May  6 14:38 ..
-rwxrwxrwx 1 pi www-data 131072 Apr  4 07:04 robotAI.sqlite

So if the file /home/pi/robotAI/static/sqlite/robotAI.sqlite is owned by the www-data group, and has permissions of rwx at the group level then why cant I access it or see it as www-data? I have rebooted several times.

  • Just to be sure www-data was in the www-data group I also ran "sudo usermod -a -G www-data www-data". But this did nothing. – Lee Melbourne May 6 '17 at 5:14
0

Looks like the directory that you try to list only has 771 permissions (user and group can read/write, others can't), and its group is pi. Try the chmod/chown without the -R flag to set the permissions of the directory itself.

  • I actually made the directory and file both owned by www-data user AND group. Yet things still do not work. Does every directory in the chain need to be owned by the user? This is ridiculous, as it has worked in every build I have done previously. – Lee Melbourne May 6 '17 at 22:44
  • Copied the file locally to /var/www/html and set owner as www-data and group as www-data and set permissions as 777. Now NGINX can read the file, but cannot write to the file. This all makes no sense. I am going to re-build the Pi. – Lee Melbourne May 6 '17 at 23:13
  • A bit late but have you tried restarting it? – randomdude999 May 7 '17 at 6:40
0

Rebuild of pi sorted it and the usual permissions i set worked fine. Very annoying.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.