1 (edited by gallart 2021-03-20 14:01:15)

Topic: Cent OS 7 systemd service is missing RuntimeDirectory option

Hello,

On brand new Centos 7 install, fresh install of php74+fpm is deploying a systemd service that is missing RuntimeDirectory option :

File : system/php74-php-fpm.service

# It's not recommended to modify this file in-place, because it
# will be overwritten during upgrades.  If you want to customize,
# the best way is to use the "systemctl edit" command.

[Unit]
Description=The PHP FastCGI Process Manager
After=syslog.target network.target

[Service]
Type=notify
EnvironmentFile=/etc/opt/remi/php74/sysconfig/php-fpm
ExecStart=/opt/remi/php74/root/usr/sbin/php-fpm --nodaemonize
ExecReload=/bin/kill -USR2 $MAINPID
PrivateTmp=true

[Install]
WantedBy=multi-user.target

Compared to default Centos 7 PHP service :

# It's not recommended to modify this file in-place, because it
# will be overwritten during upgrades.  If you want to customize,
# the best way is to use the "systemctl edit" command.

[Unit]
Description=The PHP FastCGI Process Manager
After=syslog.target network.target

[Service]
Type=notify
EnvironmentFile=/etc/sysconfig/php-fpm
ExecStart=/usr/sbin/php-fpm --nodaemonize
ExecReload=/bin/kill -USR2 $MAINPID
PrivateTmp=true
RuntimeDirectory=php-fpm
RuntimeDirectoryMode=0755

[Install]
WantedBy=multi-user.target

This is of course an issue because /var/run/php-fpm is then not present at service start.

Thanks

Gaëtan

Re: Cent OS 7 systemd service is missing RuntimeDirectory option

1/ Base packages

(php-fpm from official repository or from remi-php*)

FPM use /run/php-fpm which is managed by systemd at service startup (RuntimeDirectory), because /run is a tmpfs directory.

$ grep run /etc/php-fpm.conf
pid = /run/php-fpm/php-fpm.pid

2/ Software Collections

(php74-php-fpm from remi-safe repository)

Designed for multi-versions installations

FPM use /var/opt/remi/php74/run/php-fpm which is created at RPM installation time, this is a permanent directory

$ grep run /etc/opt/remi/php74/php-fpm.conf
pid = /var/opt/remi/php74/run/php-fpm/php-fpm.pid

If you want to switch listen to a local socket (instead of network address), of course you have to use this directory

Ex (in Fedora or CentOS 8 packages)

$ grep run /etc/opt/remi/php74/php-fpm.conf /etc/opt/remi/php74/php-fpm.d/www.conf
/etc/opt/remi/php74/php-fpm.conf:pid = /var/opt/remi/php74/run/php-fpm/php-fpm.pid
/etc/opt/remi/php74/php-fpm.d/www.conf:listen = /var/opt/remi/php74/run/php-fpm/www.sock

So I don't see any issue.

Please describe the issue you encounter.

Laptop:  Fedora 38 + rpmfusion + remi (SCL only)
x86_64 builder: Fedora 39 + rpmfusion + remi-test
aarch64 builder: RHEL 9 with EPEL
Hosting Server: CentOS 8 Stream with EPEL, rpmfusion, remi