From 6992dbb2c40b3b2d76250f0727eabc993725bcb4 Mon Sep 17 00:00:00 2001 From: Peter Kokot Date: Wed, 25 Sep 2024 20:47:20 +0200 Subject: [PATCH] Autotools: Use runstatedir for var/run directory This removes duplicate substituted variables in FPM SAPI. The php_fpm_sysconfdir is the same as EXPANDED_SYSCONFDIR and php_fpm_localstatedir is the same as EXPANDED_LOCALSTATEDIR, which are already done in the configure.ac. Instead of hardcoding the var/run directory, the runstatedir can be used (configured also via the `--runstatedir` configure option). By default, the runstatedir is `${localstatedir}/run`. --- configure.ac | 3 +++ sapi/fpm/Makefile.frag | 2 +- sapi/fpm/config.m4 | 4 ---- sapi/fpm/init.d.php-fpm.in | 2 +- sapi/fpm/php-fpm.8.in | 8 ++++---- sapi/fpm/php-fpm.conf.in | 2 +- sapi/fpm/php-fpm.service.in | 2 +- sapi/phpdbg/Makefile.frag | 2 +- 8 files changed, 12 insertions(+), 13 deletions(-) diff --git a/configure.ac b/configure.ac index 56c22f1a80f5d..e50ad1b134ce7 100644 --- a/configure.ac +++ b/configure.ac @@ -1349,6 +1349,7 @@ dnl Expand all directory names for use in macros/constants. EXPANDED_PEAR_INSTALLDIR=$(eval echo $PEAR_INSTALLDIR) EXPANDED_EXTENSION_DIR=$(eval echo $EXTENSION_DIR) EXPANDED_LOCALSTATEDIR=$(eval echo $localstatedir) +EXPANDED_RUNSTATEDIR=$(eval echo $runstatedir) EXPANDED_BINDIR=$(eval echo $bindir) EXPANDED_SBINDIR=$(eval echo $sbindir) EXPANDED_MANDIR=$(eval echo $mandir) @@ -1373,6 +1374,7 @@ AC_SUBST([EXPANDED_LIBDIR]) AC_SUBST([EXPANDED_DATADIR]) AC_SUBST([EXPANDED_SYSCONFDIR]) AC_SUBST([EXPANDED_LOCALSTATEDIR]) +AC_SUBST([EXPANDED_RUNSTATEDIR]) AC_SUBST([EXPANDED_PHP_CONFIG_FILE_PATH]) AC_SUBST([EXPANDED_PHP_CONFIG_FILE_SCAN_DIR]) AC_SUBST([PHP_INSTALLED_SAPIS]) @@ -1439,6 +1441,7 @@ PHP_SUBST([mandir]) PHP_SUBST([phptempdir]) PHP_SUBST([prefix]) PHP_SUBST([localstatedir]) +PHP_SUBST([runstatedir]) PHP_SUBST([datadir]) PHP_SUBST([datarootdir]) PHP_SUBST([sysconfdir]) diff --git a/sapi/fpm/Makefile.frag b/sapi/fpm/Makefile.frag index c6a290f9d59bf..a0eb58c35bd40 100644 --- a/sapi/fpm/Makefile.frag +++ b/sapi/fpm/Makefile.frag @@ -7,7 +7,7 @@ install-fpm: $(SAPI_FPM_PATH) @echo "Installing PHP FPM binary: $(INSTALL_ROOT)$(sbindir)/" @$(mkinstalldirs) $(INSTALL_ROOT)$(sbindir) @$(mkinstalldirs) $(INSTALL_ROOT)$(localstatedir)/log - @$(mkinstalldirs) $(INSTALL_ROOT)$(localstatedir)/run + @$(mkinstalldirs) $(INSTALL_ROOT)$(runstatedir) @$(INSTALL) -m 0755 $(SAPI_FPM_PATH) $(INSTALL_ROOT)$(sbindir)/$(program_prefix)php-fpm$(program_suffix)$(EXEEXT) @if test -f "$(INSTALL_ROOT)$(sysconfdir)/php-fpm.conf"; then \ diff --git a/sapi/fpm/config.m4 b/sapi/fpm/config.m4 index 4d4952eee86e7..df8c76aa54c5a 100644 --- a/sapi/fpm/config.m4 +++ b/sapi/fpm/config.m4 @@ -499,10 +499,6 @@ if test "$PHP_FPM" != "no"; then AC_SUBST([php_fpm_user]) AC_SUBST([php_fpm_group]) - php_fpm_sysconfdir=$(eval echo $sysconfdir) - AC_SUBST([php_fpm_sysconfdir]) - php_fpm_localstatedir=$(eval echo $localstatedir) - AC_SUBST([php_fpm_localstatedir]) php_fpm_prefix=$(eval echo $prefix) AC_SUBST([php_fpm_prefix]) diff --git a/sapi/fpm/init.d.php-fpm.in b/sapi/fpm/init.d.php-fpm.in index e54e020287376..1ecddfd4a2505 100644 --- a/sapi/fpm/init.d.php-fpm.in +++ b/sapi/fpm/init.d.php-fpm.in @@ -15,7 +15,7 @@ exec_prefix=@exec_prefix@ php_fpm_BIN=@sbindir@/php-fpm php_fpm_CONF=@sysconfdir@/php-fpm.conf -php_fpm_PID=@localstatedir@/run/php-fpm.pid +php_fpm_PID=@runstatedir@/php-fpm.pid php_opts="--fpm-config $php_fpm_CONF --pid $php_fpm_PID" diff --git a/sapi/fpm/php-fpm.8.in b/sapi/fpm/php-fpm.8.in index 941b911ed08f3..b75eaa42e89e0 100644 --- a/sapi/fpm/php-fpm.8.in +++ b/sapi/fpm/php-fpm.8.in @@ -8,9 +8,9 @@ php-fpm \- PHP FastCGI Process Manager 'PHP-FPM' .LP .SH DESCRIPTION \fBPHP\fP is a widely\-used general\-purpose scripting language that is especially suited for -Web development and can be embedded into HTML. This is a variant of PHP that will run in the background as a daemon, listening for CGI requests. Output is logged to @php_fpm_localstatedir@/log/php-fpm.log. +Web development and can be embedded into HTML. This is a variant of PHP that will run in the background as a daemon, listening for CGI requests. Output is logged to @EXPANDED_LOCALSTATEDIR@/log/php-fpm.log. .LP -Most options are set in the configuration file. The configuration file is @php_fpm_sysconfdir@/php-fpm.conf. By default, php-fpm will respond to CGI requests listening on localhost http port 9000. Therefore php-fpm expects your webserver to forward all requests for '.php' files to port 9000 and you should edit your webserver configuration file appropriately. +Most options are set in the configuration file. The configuration file is @EXPANDED_SYSCONFDIR@/php-fpm.conf. By default, php-fpm will respond to CGI requests listening on localhost http port 9000. Therefore php-fpm expects your webserver to forward all requests for '.php' files to port 9000 and you should edit your webserver configuration file appropriately. .SH OPTIONS .TP 15 .B \-C @@ -97,7 +97,7 @@ Specify the PID file location. .TP .PD 1 .B \-y -Specify alternative path to FastCGI process manager configuration file (the default is @php_fpm_sysconfdir@/php-fpm.conf) +Specify alternative path to FastCGI process manager configuration file (the default is @EXPANDED_SYSCONFDIR@/php-fpm.conf) .TP .PD 0 .B \-\-test @@ -156,7 +156,7 @@ For any unix systems which use systemd for their main process manager, you shoul sudo systemctl start php-fpm.service .RE .TP -If your installation has no appropriate init script, launch php-fpm with no arguments. It will launch as a daemon (background process) by default. The file @php_fpm_localstatedir@/run/php-fpm.pid determines whether php-fpm is already up and running. Once started, php-fpm then responds to several POSIX signals: +If your installation has no appropriate init script, launch php-fpm with no arguments. It will launch as a daemon (background process) by default. The file @EXPANDED_RUNSTATEDIR@/php-fpm.pid determines whether php-fpm is already up and running. Once started, php-fpm then responds to several POSIX signals: .P .PD 0 .RS diff --git a/sapi/fpm/php-fpm.conf.in b/sapi/fpm/php-fpm.conf.in index f1b48adca08f2..4efc4c2090315 100644 --- a/sapi/fpm/php-fpm.conf.in +++ b/sapi/fpm/php-fpm.conf.in @@ -139,4 +139,4 @@ ; Relative path can also be used. They will be prefixed by: ; - the global prefix if it's been set (-p argument) ; - @prefix@ otherwise -include=@php_fpm_sysconfdir@/php-fpm.d/*.conf +include=@EXPANDED_SYSCONFDIR@/php-fpm.d/*.conf diff --git a/sapi/fpm/php-fpm.service.in b/sapi/fpm/php-fpm.service.in index 50a87dc555f41..b4437f898eb6c 100644 --- a/sapi/fpm/php-fpm.service.in +++ b/sapi/fpm/php-fpm.service.in @@ -8,7 +8,7 @@ After=network.target [Service] Type=@php_fpm_systemd@ -PIDFile=@EXPANDED_LOCALSTATEDIR@/run/php-fpm.pid +PIDFile=@EXPANDED_RUNSTATEDIR@/php-fpm.pid ExecStart=@EXPANDED_SBINDIR@/php-fpm --nodaemonize --fpm-config @EXPANDED_SYSCONFDIR@/php-fpm.conf ExecReload=/bin/kill -USR2 $MAINPID diff --git a/sapi/phpdbg/Makefile.frag b/sapi/phpdbg/Makefile.frag index a069a23685d92..fa99ea192d498 100644 --- a/sapi/phpdbg/Makefile.frag +++ b/sapi/phpdbg/Makefile.frag @@ -24,7 +24,7 @@ install-phpdbg: $(BUILD_BINARY) @echo "Installing phpdbg binary: $(INSTALL_ROOT)$(bindir)/" @$(mkinstalldirs) $(INSTALL_ROOT)$(bindir) @$(mkinstalldirs) $(INSTALL_ROOT)$(localstatedir)/log - @$(mkinstalldirs) $(INSTALL_ROOT)$(localstatedir)/run + @$(mkinstalldirs) $(INSTALL_ROOT)$(runstatedir) @$(INSTALL) -m 0755 $(BUILD_BINARY) $(INSTALL_ROOT)$(bindir)/$(program_prefix)phpdbg$(program_suffix)$(EXEEXT) @echo "Installing phpdbg man page: $(INSTALL_ROOT)$(mandir)/man1/" @$(mkinstalldirs) $(INSTALL_ROOT)$(mandir)/man1