Wrong perms when installing Apache2
by Usalabs from LinuxQuestions.org on (#4ZBKG)
OK, here's the big problem, I've installed headless Ubuntu server 18.04 LTS on a home server (Dell PowerEdge T710), and when I installed Apache, then PHP and all the needed modules, I noticed that apt installs Apache as root and when it configures Apache, the Apache root directories and all other sub-directories are root:root so when I upload any web files, either as HTML or PHP, they too are changed to root:root, then when I try to use a php site installer (such as SMF) which checks specific file permissions during install and does the changing via FTP, the PHP error log shows an error:-
chmod 777 attachments - Operation not permitted
So after hours of investigations, I found it's because of the user:group set to root:root of Apache's document root directory, is not allowing the FTP module to change perms, but if I manually change the user:group of the directory and it's sub-directories to www-data:www-data (using chown -R www-data:www-data /var/www/html) then it all works fine.
When apt installs and configures Apache, why doesn't is change Apache's document root directory to the proper user:group of www-data:www-data?


chmod 777 attachments - Operation not permitted
So after hours of investigations, I found it's because of the user:group set to root:root of Apache's document root directory, is not allowing the FTP module to change perms, but if I manually change the user:group of the directory and it's sub-directories to www-data:www-data (using chown -R www-data:www-data /var/www/html) then it all works fine.
When apt installs and configures Apache, why doesn't is change Apache's document root directory to the proper user:group of www-data:www-data?