Server configuration - permissions and user setup issues

Hi Craig,

Thanks so much for your Magento 2.3 server from scratch guide, it’s a life saver.

That being said, I do have a weird issue.
Now I will concede I strayed from your guide slightly in that I am running Ubuntu 20.04, but other than that the setup steps I followed were exact to your guide. (I did use the steps in the 2.4 guide to run the MySQL authentication fix).

The issue I have however is that whenever I run a cli php command (ie magento setup:upgrade to install a module) the resulting files have www-data:www-data as the owner instead of magento:www-data as the owner.

(Before you ask: yes, I am using the magento user when running those commands).

It’s a pretty easy work around to just su as my super user and then run the chown command, but do you have any suggestions about why it’s doing this? Testing the PHP output, PHP itself claims to be using the magento user but I’m a bit dubious on that and not sure how to troubleshoot it further…