Php与python守护进程交互 - 文件权限

I got a python daemon running on my raspberry pi (as user pi), and I want to change its settings - which are saved in json files - via php.

It occurred to me, that I would have to either:

  • change the permissions of every file i create with python or php to something like 0666
  • change the owner to pi and the group www-data - for every file
  • run the daemon as www-data
  • create a new user and run both php and the daemon as this user

None of these really feels 'right'...

What would be the best/a good practice to do this? (or is this way of interaction "wrong"? )