0

I have looked at multiple questions about this issue and very few are resolved.

Basically I want to allow both my user and apache (www-data) to modify a file without using chmod 777 permissions.

I added my user to the www-data group and the www-data user to my user group. Using id and group on my user and the www-data user shows both are in each others group.

The file in question is located in /home/myuser/workspace/project/logs/log.txt and its permissions are 644 - myuser:www-data with the folder it is in as 755 - myuser:www-data

This allows my application to write to the file (under my user) but apache cannot access the file. When I swap user permissions around myuser:www-data -> www-data:myuser then apache can access the file but my application cannot write to the file.

I have no idea what I am overlooking.

myol
  • 181
  • 2
  • 2
  • 12

2 Answers2

0

You can use suEXEC to run application with user's uid/gid.

Gea-Suan Lin
  • 646
  • 4
  • 6
0

Ok, the answer is obvious now that I've looked into permissions a little more. Most documentation recommends folders to be set at 755 and files 644.

The first number is the user access and the second the user. In order to allow both the user and group to write to the file, the permissions need to be 664

So for all files and folders in a certain (limited) directory sudo chmod -R u+rw,g+rw

myol
  • 181
  • 2
  • 2
  • 12