I use Ubuntu 20.04. I have edited /etc/apache2/envvars to change the run user to "userA":
export APACHE_RUN_USER=userA
When I run this PHP script from W3 Schools to upload a file, the upload works - but the owner of the file is not "userA" as I intend. It remains www-data. Yet this command: sudo apache2ctl -S
reports User: name="userA" id=1002
, as set in envvars. So why does www-data own the file, and not userA? What is determining file ownership? FWIW, the permissions of the directory into which the file is uploaded are 774, and ownership is userA:www-data. "Set UID" and/or "Set GID" on the directory had no impact either.
I will add that if I drag and drop a file in the directory with WinSCP (using ssh), the ownership is userA:userA (yes, userA is a member of both the userA group and www-data group). If I Set GID and drag and drop, the owner is userA:www-data.
source https://stackoverflow.com/questions/67892965/ubuntu-20-04-apache-file-ownership-and-envvars
No comments:
Post a Comment