Run httpd as user other than apache

Issues related to applications and software problems and general support
Post Reply
davewithheld
Posts: 3
Joined: 2022/08/13 04:43:08

Run httpd as user other than apache

Post by davewithheld » 2022/08/13 05:55:39

I am trying to run httpd (apache) as a different user. I have set the user and group in /etc/httpd/conf/httpd.conf as well as in /etc/php-fpm.d/www.conf (where I also added the user to listen.acl_users). apache and php work fine, but in order to get .cgi scripts to run, I have to set the user's group on /run/httpd. As soon as I do (no restart of services required), .cgi scripts run fine.

Since /run is a tmpfs, the changes get reset on boot. The question I have is how is the /run/httpd directory created? If I disable the httpd service, the directory is still created, and always with apache as the group. What process creates that directory and where do I change the group name it uses to create it?

Something I might mention is that I have a Fedora 35 system that also has apache as the group for /run/httpd but it has no problem running .cgi or php.

One other thing: selinux is set to permissive while I get this stuff working.

User avatar
TrevorH
Site Admin
Posts: 33202
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Run httpd as user other than apache

Post by TrevorH » 2022/08/13 13:41:07

The question I have is how is the /run/httpd directory created?
Created by tmpfiles.d via a config file in /usr/lib/tmpfiles.d
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

User avatar
jlehtone
Posts: 4523
Joined: 2007/12/11 08:17:33
Location: Finland

Re: Run httpd as user other than apache

Post by jlehtone » 2022/08/13 13:51:29

Therefore, one can override the defaults with config file in /etc/tmpfiles.d
See https://www.freedesktop.org/software/sy ... les.d.html

Likewise, the settings of httpd.service can be augmented or replaced with files under /etc/systemd/system/

User avatar
TrevorH
Site Admin
Posts: 33202
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Run httpd as user other than apache

Post by TrevorH » 2022/08/13 14:26:34

But be aware that the httpd package is built assuming that it uses the correct user and all ownership of files that the package contains will be reset to httpd on package upgrade.
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

User avatar
jlehtone
Posts: 4523
Joined: 2007/12/11 08:17:33
Location: Finland

Re: Run httpd as user other than apache

Post by jlehtone » 2022/08/13 16:56:19

davewithheld wrote:
2022/08/13 05:55:39
I am trying to run httpd (apache) as a different user.
Should we ask: "Why"?

We want to rule out XY-problem.

Post Reply