I'm using PHP on an Apache web server, but PHP lacks write permission and can't create new files, or modify existing ones, despite that the file that needs to be modified is set to the usual 644 (and folders are 755).
My first guess was that the problem was PHP running as a different user than the file owner, and by running "posix_getpwuid(posix_geteuid());" I found that PHP ran as "www-data", while the file had owner and group set to "company123". So maybe I should simply change the owner of the file to "www-data"?
But then I decided to check some other web servers I've been working with. On the first one I tried, I had no problems creating or modifying 644 files with PHP, and yet, the owner and group were named "600", while PHP ran as the user "wse253421". So apparently, it's ok for PHP to run as one user, and write to 644 files owned by another user. How does that work?
What's going on here, and what should I do about PHP lacking write permission on the first server?