Get Apache to create files as the web site owner

20 views Asked by At

I have a couple of PHP sites running on Apache hosted on Rocky 8 (Redhat). Each site has an owner e.g. mysite1admin, mysite2admin.

[root@MyWebServer01 ~]# ls -latrh /var/www/vhosts/
total 0
drwxrwsr-x. 6 root            webadmin 149 Jan 12  2023 .
drwxr-xr-x. 5 root            root      47 May 17  2023 ..
drwxrwsr-x. 6 mysite1admin webadmin  75 Nov 20 09:18 my-site-1.co.uk
drwxrwsr-x. 5 mysite2admin webadmin  63 Dec 21 16:00 my-site-2.co.uk

Apache (httpd) writes files (cache, logs) in each site but these files are owned by Apache.

Is there a way to get a process, in this case Apache, to create files as the owner of the directory e.g. mysite1admin ?

[root@MyWebServer01 ~]# ls -latrh /var/www/vhosts/my-site-1.co.uk/current/var/cache/prod/
total 376K
drwxrwsr-x+ 3 mysite1admin webadmin   18 Nov 20 09:18 ..
-rw-rwxr--+ 1 mysite1admin webadmin    0 Nov 20 09:18 App_KernelProdContainer.php.lock
-rw-rwxr--+ 1 mysite1admin webadmin  21K Nov 20 09:18 annotations.map
drwxrwsr-x+ 2 mysite1admin webadmin  28K Nov 20 09:18 ContainerYxkpfyH
-rw-rwxr--+ 1 mysite1admin webadmin  743 Nov 20 09:18 App_KernelProdContainer.php
-rw-rwxr--+ 1 mysite1admin webadmin 124K Nov 20 09:18 App_KernelProdContainer.php.meta
-rw-rwxr--+ 1 apache       webadmin 6.3K Nov 20 09:20 url_generating_routes.php.meta
-rw-rwxr--+ 1 apache       webadmin  36K Nov 20 09:20 url_generating_routes.php
0

There are 0 answers