Skip to content
This repository has been archived by the owner on May 18, 2022. It is now read-only.

Commit

Permalink
Fix PHP FPM bug in the initd script
Browse files Browse the repository at this point in the history
  • Loading branch information
petk committed May 18, 2018
1 parent 55d740a commit 5900e86
Show file tree
Hide file tree
Showing 10 changed files with 151 additions and 147 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
All notable changes to this project will be documented in this file. This project
[keeps a CHANGELOG](http://keepachangelog.com/) based on the time changes.

## 2018-05-18

* PHP FPM bug #2 fixed: Wrong location of pid and sock files

## 2018-05-08

* Move repository location to github.com/phpearth and update outdated repo info
Expand Down
8 changes: 4 additions & 4 deletions build/v3.7/php7.0/APKBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pkgname=php7.0
_pkgreal=php
_phpver=7.0
pkgver=7.0.30
pkgrel=0
pkgrel=1
_apiver=20151012
pkgdesc="The PHP $_phpver language runtime engine"
url="http://www.php.net/"
Expand Down Expand Up @@ -466,9 +466,9 @@ fpm() {
done

# Fix FPM versions in configuration files
sed -i 's/\;pid \= run\/php-fpm\.pid/pid \= \/run\/php\/php-fpm7\.0\.pid/g' "$subpkgdir"/etc/php/$_phpver/php-fpm.conf
sed -i 's/\;pid \= run\/php-fpm\.pid/pid \= \/run\/php-fpm7\.0\/php-fpm\.pid/g' "$subpkgdir"/etc/php/$_phpver/php-fpm.conf
sed -i 's/\;error\_log \= log\/php-fpm\.log/error\_log \= \/var\/log\/php\/7\.0\/php-fpm\.log/g' "$subpkgdir"/etc/php/$_phpver/php-fpm.conf
sed -i 's/listen \= 127\.0\.0\.1\:9000/listen \= \/run\/php\/php-fpm7\.0\.sock/g' "$subpkgdir"/etc/php/$_phpver/php-fpm.d/www.conf
sed -i 's/listen \= 127\.0\.0\.1\:9000/listen \= \/run\/php-fpm7\.0\/php-fpm\.sock/g' "$subpkgdir"/etc/php/$_phpver/php-fpm.d/www.conf
sed -i 's/\;listen\.owner \= www-data/listen\.owner \= www-data/g' "$subpkgdir"/etc/php/$_phpver/php-fpm.d/www.conf
sed -i 's/\;listen\.group \= www-data/listen\.group \= www-data/g' "$subpkgdir"/etc/php/$_phpver/php-fpm.d/www.conf

Expand Down Expand Up @@ -614,7 +614,7 @@ sha512sums="1f0914ebda79247aa65ace63f6c8c4fcd850b21a82704f7b6482760259239cc5fee4
1eb894661d4a9cb7cb07d2c507f8b6a52cd62dac18f73c31f2c2bf6f7e7b0c185b74a542481a29cef4236353cf278bd86aa183663d5999f0b8df8c7623366c2b install-pear.patch
8a793255617a1b48a6e1dbc04ca3740c1214827c5d549c16fd9756ba7302d64b75a415e81516522af1ae98ef0e18d06573deaa017b484b15523a2d1944ef015a pear.patch
ea05e681c952ce72d7661b9097c8a994e4e52de8155fe2ef6350d034f52a243c27f73b9b9faf7d056237737d8049047d4e985644169f71eaa596d80d4e25204e pecl.sh
f20c5dfa88bcbca2adf10a792ea420edb26c3d7e3428b4e49f07a6e5b9ae52a8270b6087b46899036dc86ba1962c92b535be56f31a6a9c341f73cded67698cab php-fpm.initd
62135bbe57290259ab55c00279c4e369d3bfe80e91bef5c2dfcbe596f50ceba28f4ce13488e0cd614cb54cec1c50815352964a2bf194f6f3b3efd5071b1515b5 php-fpm.initd
3a8fa61867526355ba0278b83f01a104a591c46dba4b96d600f5b66bebee30e6aa18b579dbee371f87166a2c9dff3ba7cc5faf2f836dfc91fa5a94970e535fec php-fpm.logrotate
274bd7b0b2b7002fa84c779640af37b59258bb37b05cb7dd5c89452977d71807f628d91b523b5039608376d1f760f3425d165242ca75ee5129b2730e71c4e198 php7-module.conf
6894c9cba7752a3406e774d9efc0e058c37433493c1c20101e9563bf247c112157a67e306b06b9517b0422eca521f543d637a6cbd2cea7639e43f13d773b3d2b tidy-buffio.patch"
88 changes: 44 additions & 44 deletions build/v3.7/php7.0/php-fpm.initd
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
command="/usr/sbin/php-fpm7.0"
command_background="yes"
start_stop_daemon_args="--quiet"
pidfile="/run/$RC_SVCNAME/php-fpm7.0.pid"
pidfile="/run/$RC_SVCNAME/php-fpm.pid"
retry="SIGTERM/20"

# configtest is here only for backward compatibility
Expand All @@ -24,70 +24,70 @@ description_reopen="Reopen log files"
required_files="$fpm_config"

depend() {
need net
use apache2 lighttpd nginx
need net
use apache2 lighttpd nginx
}

init_vars() {
# Defaults for single master process with multiple pools
if [ "$RC_SVCNAME" = "php-fpm7.0" ]; then
: ${fpm_config:="/etc/php/7.0/php-fpm.conf"}
: ${user:="root"}
# Defaults for master process per pool
else
: ${fpm_config="/etc/php/7.0/php-fpm.d/${RC_SVCNAME#php-fpm.}.conf"}
: ${user:="$(conf_get user)"}
: ${user:="www-data"}
: ${group:="$(conf_get group)"}
fi
command_args="--nodaemonize --fpm-config $fpm_config"
start_stop_daemon_args="$start_stop_daemon_args
--user $user ${group:+"--group $group"}"
# Defaults for single master process with multiple pools
if [ "$RC_SVCNAME" = "php-fpm7.0" ]; then
: ${fpm_config:="/etc/php/7.0/php-fpm.conf"}
: ${user:="root"}
# Defaults for master process per pool
else
: ${fpm_config="/etc/php/7.0/php-fpm.d/${RC_SVCNAME#php-fpm.}.conf"}
: ${user:="$(conf_get user)"}
: ${user:="www-data"}
: ${group:="$(conf_get group)"}
fi
command_args="--nodaemonize --fpm-config $fpm_config"
start_stop_daemon_args="$start_stop_daemon_args
--user $user ${group:+"--group $group"}"
}

start_pre() {
checkconfig || return 1
checkconfig || return 1

# If unix socket is used (instead of TCP/IP), then ensure that the
# directory exists and has correct privileges.
local listen="$(conf_get listen)"
if [ "${listen:0:1}" = "/" ]; then
checkpath -d -o $user:$group "$(dirname "$listen")"
fi
# If unix socket is used (instead of TCP/IP), then ensure that the
# directory exists and has correct privileges.
local listen="$(conf_get listen)"
if [ "${listen:0:1}" = "/" ]; then
checkpath -d -o $user:$group "$(dirname "$listen")"
fi

checkpath -d "$(dirname "$pidfile")"
checkpath -d "$(dirname "$pidfile")"
}

reload() {
ebegin "Reloading $name"
start-stop-daemon --signal USR2 --pidfile "$pidfile"
eend $?
ebegin "Reloading $name"
start-stop-daemon --signal USR2 --pidfile "$pidfile"
eend $?
}

reopen() {
ebegin "Reopening $name log files"
start-stop-daemon --signal USR1 --pidfile "$pidfile"
eend $?
ebegin "Reopening $name log files"
start-stop-daemon --signal USR1 --pidfile "$pidfile"
eend $?
}

checkconfig() {
init_vars
ebegin "Checking $fpm_config"

local out
out="$(su -s /bin/sh -c "$command --test --fpm-config $fpm_config" $user 2>&1)" || {
printf "%s\n" "$out"
eend 1 "failed, please correct errors above"
return 1
}
init_vars
ebegin "Checking $fpm_config"

local out
out="$(su -s /bin/sh -c "$command --test --fpm-config $fpm_config" $user 2>&1)" || {
printf "%s\n" "$out"
eend 1 "failed, please correct errors above"
return 1
}
}

configtest() {
ewarn "configtest is deprecated, use checkconfig instead"
checkconfig
ewarn "configtest is deprecated, use checkconfig instead"
checkconfig
}

conf_get() {
local key="$1"
sed -nE "s/^${key}\s*=\s*\"?([^\";]+).*/\1/p" "$fpm_config" | head -n 1
local key="$1"
sed -nE "s/^${key}\s*=\s*\"?([^\";]+).*/\1/p" "$fpm_config" | head -n 1
}
2 changes: 1 addition & 1 deletion build/v3.7/php7.0/php7.0-fpm.post-install
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ link=$(readlink /usr/sbin/php-fpm)

if [[ "$link" != "/usr/sbin/php-fpm7.1" && "$link" != "/usr/sbin/php-fpm7.2" ]] || [[ ! -f "$link" ]]; then
ln -sf /usr/sbin/php-fpm$_suffix /usr/sbin/php-fpm
ln -sf /run/php/php-fpm$_suffix.sock /run/php/php-fpm.sock
ln -sf /run/php-fpm$_suffix/php-fpm.sock /run/php/php-fpm.sock
fi
8 changes: 4 additions & 4 deletions build/v3.7/php7.1/APKBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pkgname=php7.1
_pkgreal=php
_phpver=7.1
pkgver=7.1.17
pkgrel=0
pkgrel=1
_apiver=20160303
pkgdesc="The PHP $_phpver language runtime engine"
url="http://www.php.net/"
Expand Down Expand Up @@ -464,9 +464,9 @@ fpm() {
done

# Fix FPM versions in configuration files
sed -i 's/\;pid \= run\/php-fpm\.pid/pid \= \/run\/php\/php-fpm7\.1\.pid/g' "$subpkgdir"/etc/php/$_phpver/php-fpm.conf
sed -i 's/\;pid \= run\/php-fpm\.pid/pid \= \/run\/php-fpm7\.1\/php-fpm\.pid/g' "$subpkgdir"/etc/php/$_phpver/php-fpm.conf
sed -i 's/\;error\_log \= log\/php-fpm\.log/error\_log \= \/var\/log\/php\/7\.1\/php-fpm\.log/g' "$subpkgdir"/etc/php/$_phpver/php-fpm.conf
sed -i 's/listen \= 127\.0\.0\.1\:9000/listen \= \/run\/php\/php-fpm7\.1\.sock/g' "$subpkgdir"/etc/php/$_phpver/php-fpm.d/www.conf
sed -i 's/listen \= 127\.0\.0\.1\:9000/listen \= \/run\/php-fpm7\.1\/php-fpm\.sock/g' "$subpkgdir"/etc/php/$_phpver/php-fpm.d/www.conf
sed -i 's/\;listen\.owner \= www-data/listen\.owner \= www-data/g' "$subpkgdir"/etc/php/$_phpver/php-fpm.d/www.conf
sed -i 's/\;listen\.group \= www-data/listen\.group \= www-data/g' "$subpkgdir"/etc/php/$_phpver/php-fpm.d/www.conf

Expand Down Expand Up @@ -613,6 +613,6 @@ cd76bd6a6a222e17ba50a11d292925966e30532a464ad2807d8ae5a8c510c63eeb494291f0b0ce1d
1eb894661d4a9cb7cb07d2c507f8b6a52cd62dac18f73c31f2c2bf6f7e7b0c185b74a542481a29cef4236353cf278bd86aa183663d5999f0b8df8c7623366c2b install-pear.patch
8a793255617a1b48a6e1dbc04ca3740c1214827c5d549c16fd9756ba7302d64b75a415e81516522af1ae98ef0e18d06573deaa017b484b15523a2d1944ef015a pear.patch
16e89446e3ef1d8da82efcbf8c79155c3a8d25494051c53bab88ef578f88918860a55214c91defe34ab2e3a45b23c3d068172a4d878aaf6e3dd58e78734ee059 pecl.sh
bdfc4a1caaadd49151cda5af6b011e17f5404927d427a51826415c15f839b6d65f8dc5532ad346be2da349de407db127c1203de432fb487b8a3ee79ac42106a0 php-fpm.initd
4cb9d4d5ea8b1eb65be9c3b59c34577c0713cf5d60d7053a410bacc8df36e685e881b4e7623539201aea05e7dd7314d6f0063c2437cf34b7467033f254b669c6 php-fpm.initd
0ebb6f6ffa2ed613b966d88161e8cc46633ee18b3a399f05de4782ebe8aacc5206ce1259f8ea873fbb3df11c7c68728670695ef35e4696a5b00d0c2bbd597b80 php-fpm.logrotate
274bd7b0b2b7002fa84c779640af37b59258bb37b05cb7dd5c89452977d71807f628d91b523b5039608376d1f760f3425d165242ca75ee5129b2730e71c4e198 php7-module.conf"
88 changes: 44 additions & 44 deletions build/v3.7/php7.1/php-fpm.initd
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
command="/usr/sbin/php-fpm7.1"
command_background="yes"
start_stop_daemon_args="--quiet"
pidfile="/run/$RC_SVCNAME/php-fpm7.1.pid"
pidfile="/run/$RC_SVCNAME/php-fpm.pid"
retry="SIGTERM/20"

# configtest is here only for backward compatibility
Expand All @@ -24,70 +24,70 @@ description_reopen="Reopen log files"
required_files="$fpm_config"

depend() {
need net
use apache2 lighttpd nginx
need net
use apache2 lighttpd nginx
}

init_vars() {
# Defaults for single master process with multiple pools
if [ "$RC_SVCNAME" = "php-fpm7.1" ]; then
: ${fpm_config:="/etc/php/7.1/php-fpm.conf"}
: ${user:="root"}
# Defaults for master process per pool
else
: ${fpm_config="/etc/php/7.1/php-fpm.d/${RC_SVCNAME#php-fpm.}.conf"}
: ${user:="$(conf_get user)"}
: ${user:="www-data"}
: ${group:="$(conf_get group)"}
fi
command_args="--nodaemonize --fpm-config $fpm_config"
start_stop_daemon_args="$start_stop_daemon_args
--user $user ${group:+"--group $group"}"
# Defaults for single master process with multiple pools
if [ "$RC_SVCNAME" = "php-fpm7.1" ]; then
: ${fpm_config:="/etc/php/7.1/php-fpm.conf"}
: ${user:="root"}
# Defaults for master process per pool
else
: ${fpm_config="/etc/php/7.1/php-fpm.d/${RC_SVCNAME#php-fpm.}.conf"}
: ${user:="$(conf_get user)"}
: ${user:="www-data"}
: ${group:="$(conf_get group)"}
fi
command_args="--nodaemonize --fpm-config $fpm_config"
start_stop_daemon_args="$start_stop_daemon_args
--user $user ${group:+"--group $group"}"
}

start_pre() {
checkconfig || return 1
checkconfig || return 1

# If unix socket is used (instead of TCP/IP), then ensure that the
# directory exists and has correct privileges.
local listen="$(conf_get listen)"
if [ "${listen:0:1}" = "/" ]; then
checkpath -d -o $user:$group "$(dirname "$listen")"
fi
# If unix socket is used (instead of TCP/IP), then ensure that the
# directory exists and has correct privileges.
local listen="$(conf_get listen)"
if [ "${listen:0:1}" = "/" ]; then
checkpath -d -o $user:$group "$(dirname "$listen")"
fi

checkpath -d "$(dirname "$pidfile")"
checkpath -d "$(dirname "$pidfile")"
}

reload() {
ebegin "Reloading $name"
start-stop-daemon --signal USR2 --pidfile "$pidfile"
eend $?
ebegin "Reloading $name"
start-stop-daemon --signal USR2 --pidfile "$pidfile"
eend $?
}

reopen() {
ebegin "Reopening $name log files"
start-stop-daemon --signal USR1 --pidfile "$pidfile"
eend $?
ebegin "Reopening $name log files"
start-stop-daemon --signal USR1 --pidfile "$pidfile"
eend $?
}

checkconfig() {
init_vars
ebegin "Checking $fpm_config"

local out
out="$(su -s /bin/sh -c "$command --test --fpm-config $fpm_config" $user 2>&1)" || {
printf "%s\n" "$out"
eend 1 "failed, please correct errors above"
return 1
}
init_vars
ebegin "Checking $fpm_config"

local out
out="$(su -s /bin/sh -c "$command --test --fpm-config $fpm_config" $user 2>&1)" || {
printf "%s\n" "$out"
eend 1 "failed, please correct errors above"
return 1
}
}

configtest() {
ewarn "configtest is deprecated, use checkconfig instead"
checkconfig
ewarn "configtest is deprecated, use checkconfig instead"
checkconfig
}

conf_get() {
local key="$1"
sed -nE "s/^${key}\s*=\s*\"?([^\";]+).*/\1/p" "$fpm_config" | head -n 1
local key="$1"
sed -nE "s/^${key}\s*=\s*\"?([^\";]+).*/\1/p" "$fpm_config" | head -n 1
}
2 changes: 1 addition & 1 deletion build/v3.7/php7.1/php7.1-fpm.post-install
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ link=$(readlink /usr/sbin/php-fpm)

if [[ "$link" != "/usr/sbin/php-fpm7.2" || ! -f "$link" ]]; then
ln -sf /usr/sbin/php-fpm$_suffix /usr/sbin/php-fpm
ln -sf /run/php/php-fpm$_suffix.sock /run/php/php-fpm.sock
ln -sf /run/php-fpm$_suffix/php-fpm.sock /run/php/php-fpm.sock
fi
8 changes: 4 additions & 4 deletions build/v3.7/php7.2/APKBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ _pkgreal=php
_phpver=7.2
pkgver=7.2.5
# Package release number is started at 100 so it overwrites the official package
pkgrel=100
pkgrel=101
_apiver=20170718
pkgdesc="The PHP $_phpver language runtime engine"
url="http://www.php.net/"
Expand Down Expand Up @@ -476,9 +476,9 @@ fpm() {
done

# Fix FPM versions in configuration files
sed -i 's/\;pid \= run\/php-fpm\.pid/pid \= \/run\/php\/php-fpm7\.2\.pid/g' "$subpkgdir"/etc/php/$_phpver/php-fpm.conf
sed -i 's/\;pid \= run\/php-fpm\.pid/pid \= \/run\/php-fpm7\.2\/php-fpm\.pid/g' "$subpkgdir"/etc/php/$_phpver/php-fpm.conf
sed -i 's/\;error\_log \= log\/php-fpm\.log/error\_log \= \/var\/log\/php\/7\.2\/php-fpm\.log/g' "$subpkgdir"/etc/php/$_phpver/php-fpm.conf
sed -i 's/listen \= 127\.0\.0\.1\:9000/listen \= \/run\/php\/php-fpm7\.2\.sock/g' "$subpkgdir"/etc/php/$_phpver/php-fpm.d/www.conf
sed -i 's/listen \= 127\.0\.0\.1\:9000/listen \= \/run\/php-fpm7\.2\/php-fpm\.sock/g' "$subpkgdir"/etc/php/$_phpver/php-fpm.d/www.conf
sed -i 's/\;listen\.owner \= www-data/listen\.owner \= www-data/g' "$subpkgdir"/etc/php/$_phpver/php-fpm.d/www.conf
sed -i 's/\;listen\.group \= www-data/listen\.group \= www-data/g' "$subpkgdir"/etc/php/$_phpver/php-fpm.d/www.conf

Expand Down Expand Up @@ -628,7 +628,7 @@ cd76bd6a6a222e17ba50a11d292925966e30532a464ad2807d8ae5a8c510c63eeb494291f0b0ce1d
1eb894661d4a9cb7cb07d2c507f8b6a52cd62dac18f73c31f2c2bf6f7e7b0c185b74a542481a29cef4236353cf278bd86aa183663d5999f0b8df8c7623366c2b install-pear.patch
8a793255617a1b48a6e1dbc04ca3740c1214827c5d549c16fd9756ba7302d64b75a415e81516522af1ae98ef0e18d06573deaa017b484b15523a2d1944ef015a pear.patch
aeea2889de5413739b17fa37de2a0def5fbc6176d51df6e0a41ce14c0b56ba040d7637e98dcbe35d9636ceeb9a22a9145430cacaf78662cce0389a3416d09479 pecl.sh
0dde6dfaa9e03a4c84be7ba3df4321c983f4ae60b1919f29285c47db3b580bc938a2bde83c183db2460f4caf6c16261849a0a7a05d1b0b15096b4984ae16371e php-fpm.initd
2c8bb9c01ed0600fb2ed358737151232572a9dcb648cfe0545a36710a6086147d6710079c9caa2d321ccaa0fe5a6c10e5eecd09a6e9d861e84b43254cff793d5 php-fpm.initd
618e8dc8b24fb517c04644bf245f7731f75c2a5a37f9c661ca093373ffcb49fdeb246774be7a1d9e8c947bcb1efbd065866f2d33da0d7750bf029db6233a8f53 php-fpm.logrotate
274bd7b0b2b7002fa84c779640af37b59258bb37b05cb7dd5c89452977d71807f628d91b523b5039608376d1f760f3425d165242ca75ee5129b2730e71c4e198 php7-module.conf
064db21b1073b5a03aaf547c773ebc096bcfa2bbb39f6c4e8ebff1002dbfa37e8ccb5712e21e0d9b300034f43c3501d13d75cefccb00473c844bb5449e7866dc run-tests.php.patch"
Loading

0 comments on commit 5900e86

Please sign in to comment.