if you want apache to run them then making the files owned by apache is what you will need. or whatever apache user. if you need elevated access then it will get stranger.

On Thu, Oct 17, 2024 at 4:09 PM Keith Smith via PLUG-discuss <plug-discuss@lists.phxlinux.org> wrote:
Hi,

I have several Ubuntu 24.04lts servers setup on virtual box.

I am wondering about PHP file ownership and directory ownership.

It is my understanding on a Ubuntu server running Apache2 that the PHP
files and the Docroot directories should be owned by the Apache user and
group - www-data.

I asked AI and it said : "Yes, for a PHP script to be able to write to
the server (like creating files, logging, etc.) when running under
Apache, the file must be owned by the user that the Apache server runs
as, which is typically www-data on Ubuntu."

AI also gave the following:

sudo chown www-data:www-data /path/to/your/script.php

sudo chown -R www-data:www-data /path/to/your/directory

sudo chmod 644 /path/to/your/script.php

sudo chmod 755 /path/to/your/directory
---

Any thoughts are much appreciated.

Keith


---------------------------------------------------
PLUG-discuss mailing list: PLUG-discuss@lists.phxlinux.org
To subscribe, unsubscribe, or to change your mail settings:
https://lists.phxlinux.org/mailman/listinfo/plug-discuss


--
A mouse trap, placed on top of your alarm clock, will prevent you from rolling over and going back to sleep after you hit the snooze button.

Stephen