centos httpd service creates files and dirs as root and not as apache user

I performed a Centos httpd package default installation which comes up with the directives User and Group set to apache:apache. when I run :

ps -ef | grep -i http | awk '{print $1}'

it shows one process as owned by root and 4 owned by apache. Selinux is set to permissive

Nevertheless, when files or folders are created by the apache daemon (for instance the log files) their owner is always root:root.

I've deployed several Debian with the same setup and files or folders created by apache are always owned by www-data:www-data.

Any idea of what causes this difference with Centos ?

1 answer

  • answered 2020-06-02 08:28 Pandurang

    This is the expected behavior. I think you are starting apache httpd process using root user. That's why Apache httpd main process started by root user and the remaining process starts with Apache user. Apache httpd user and group is already mentioned in httpd.conf

    User apache
    Group apache