0

This started when I noticed one site was giving client denied by server configuration errors in the Apache error.log but only on certain files in one local site. The rest of the site and all other sites were fine and did not give the error. Since all had the same permissions, it seems odd but trying to kill two birds with one stone, I started looking at permissions and ownership as follows.

Trying to keep the permissions compatible between my local development system and the live server which requires 755 permissions on the folders and 644 permissions for files, I've set mine on the local development system to those same permissions using:

sudo cd /var/www/html
sudo find . -type d -exec chmod 0755 {} \;
sudo find . -type f -exec chmod 0644 {} \;

However, with those permissions and user/ownership for both as www-data I can no longer save new or edit changed files even though my own user name is part of the www-data group. I am running Apache2 on Ubuntu 20.04.

UPDATE: I didn't like having to do this but had to get it working so I made myself the owner using sudo chown -R don:www-data /var/www/html which at least it lets me keep the 644/755 file/folder permissions while still being able to read and write to the files. I would love to hear how to make it work with the proper www-data user, though!

However, the client denied by server configuration error is still there on some files in the Apache error.log file. Any ideas for getting rid of it? All files and folders have the proper permissions so not sure why this is happening on a couple files and only on one single site.

1

Try running the two commands below for the parent directory where you want things to work. Below are examples from my system.

Change all files recursively to 644

sudo find /var/www/html/moodlecnx/ -type f -exec chmod 644 {} \;

Change all directories recursively to 755

sudo find /var/www/html/moodlecnx/ -type d -exec chmod 755 {} \; 
5
  • Thank you but I’ve already changed all the file permissions. What I need to know now is what to do to be able to read and write to them. I get Permission denied errors even though I am a member of the www-data group. – DonP May 13 '20 at 3:15
  • You did not add yourself to www-data. You made the files owned by don as user and group www-data. You need to put yourself into the group www-data with this command sudo adduser {USER-NAME-HERE} {GROUP-NAME-HERE}. Actual command in your case. sudo adduser don www-data. Now you are a valid member of www-data. NOW change all the files to be owned by www-data as user and www-data as group. Apache needs that. (I think as I am a NB) – walttheboss May 13 '20 at 22:29
  • I tried so many things to get this working and adding myself to the group was one of them and I said so but didn't post the code for doing so as it had already been tried. What I posted above is what I tried AFTER that. When I had myself as a member of the group and the files owned by www-data in group www-data, I couldn't save any changes but when I took ownership I could save them. – DonP May 13 '20 at 22:42
  • Thanks for the clarification @DonP. I know the frustration. Are you working locally on the troublesome machine? Or is it remote? How are you connecting? SSH? Terminal Only? Keep on fighting. Permissions issues can be very annoying. – walttheboss May 13 '20 at 22:45
  • Working locally in Terminal only. It's my own PC so no difficulties there!. – DonP May 13 '20 at 22:53

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.