PHP files and server directory ownership under Ubuntu/Apache2
techlists at phpcoderusa.com
techlists at phpcoderusa.com
Thu Oct 17 13:09:18 MST 2024
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
More information about the PLUG-discuss
mailing list