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.

asked May 6, 2017 at 5:10
1
  • 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. Commented May 6, 2017 at 5:14

2 Answers 2

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.

answered May 6, 2017 at 17:57
3
  • 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. Commented May 6, 2017 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. Commented May 6, 2017 at 23:13
  • A bit late but have you tried restarting it? Commented May 7, 2017 at 6:40
0

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

answered May 9, 2017 at 23:00
1
  • Please accept your answer. This is the only way to finish the question and it will never pop up again for years. Commented Dec 1, 2019 at 12:49

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.