PHP files and server directory ownership under Ubuntu/Apache…

Top Page
Attachments:
Message as email
+ (text/plain)
Delete this message
Reply to this message
Author: Keith Smith via PLUG-discuss
Date:  
To: Main PLUG discussion list
CC: techlists
Subject: PHP files and server directory ownership under Ubuntu/Apache2
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:
To subscribe, unsubscribe, or to change your mail settings:
https://lists.phxlinux.org/mailman/listinfo/plug-discuss