Skip to content

Commit e3da54d

Browse files
authored
Add apk repository, update debian repository instructions (#2099)
closes #1753 closes #2156 As per discussion here #2060 (comment) I went ahead with different repos for different php versions. Versioned support with stuff like `apt install frankenphp8.5` or `apk add frankenphp85` are technically also ready, but I'm not running any CI for that yet. I don't think it's worth it at this point as it would double the amount of runs. The old debian repository with only 8.4 is deprecated but will receive updates for a few more months. Every update/installation will print this notice, though, which will hopefully make everyone aware: ```console # running update from 8.4.15... Unpacking php-zts-cli (8.4.16-1) ... Setting up php-zts-cli (8.4.16-1) ... ================================================================================ ⚠️ DEPRECATION NOTICE ================================================================================ The single-version php-zts repository is deprecated and will no longer receive updates. Please migrate to the new repository with different PHP versions available. More information: https://pkgs.henderkes.com ================================================================================ ``` Updated the installer to version 8.5.
1 parent fba79a6 commit e3da54d

File tree

11 files changed

+206
-42
lines changed

11 files changed

+206
-42
lines changed

README.md

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,9 @@ sudo pie-zts install asgrim/example-pie-extension
6060
Our maintainers offer deb packages for all systems using `apt`. To install, run:
6161

6262
```console
63-
sudo curl -fsSL https://key.henderkes.com/static-php.gpg -o /usr/share/keyrings/static-php.gpg && \
64-
echo "deb [signed-by=/usr/share/keyrings/static-php.gpg] https://deb.henderkes.com/ stable main" | sudo tee /etc/apt/sources.list.d/static-php.list && \
63+
VERSION=85 # 82-85 available
64+
sudo curl https://pkg.henderkes.com/api/packages/${VERSION}/debian/repository.key -o /etc/apt/keyrings/static-php${VERSION}.asc
65+
echo "deb [signed-by=/etc/apt/keyrings/static-php${VERSION}.asc] https://pkg.henderkes.com/api/packages/${VERSION}/debian php-zts main" | sudo tee -a /etc/apt/sources.list.d/static-php${VERSION}.list
6566
sudo apt update
6667
sudo apt install frankenphp
6768
```
@@ -75,6 +76,28 @@ sudo apt install pie-zts
7576
sudo pie-zts install asgrim/example-pie-extension
7677
```
7778

79+
### apk Packages
80+
81+
Our maintainers offer apk packages for all systems using `apk`. To install, run:
82+
83+
```console
84+
VERSION=85 # 82-85 available
85+
echo "https://pkg.henderkes.com/api/packages/${VERSION}/alpine/main/php-zts" | sudo tee -a /etc/apk/repositories
86+
KEYFILE=$(curl -sJOw '%{filename_effective}' https://pkg.henderkes.com/api/packages/${VERSION}/alpine/key)
87+
sudo mv ${KEYFILE} /etc/apk/keys/ &&
88+
sudo apk update &&
89+
sudo apk add frankenphp
90+
```
91+
92+
**Installing extensions:** `sudo apk add php-zts-<extension>`
93+
94+
For extensions not available by default, use [PIE](https://github.com/php/pie):
95+
96+
```console
97+
sudo apk add pie-zts
98+
sudo pie-zts install asgrim/example-pie-extension
99+
```
100+
78101
### Homebrew
79102

80103
FrankenPHP is also available as a [Homebrew](https://brew.sh) package for macOS and Linux.

docs/performance.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ However, it is possible to substantially improve performance using an appropriat
77

88
By default, FrankenPHP starts 2 times more threads and workers (in worker mode) than the available numbers of CPU.
99

10-
The appropriate values depend heavily on how your application is written, what it does and your hardware.
10+
The appropriate values depend heavily on how your application is written, what it does, and your hardware.
1111
We strongly recommend changing these values. For best system stability, it is recommended to have `num_threads` x `memory_limit` < `available_memory`.
1212

1313
To find the right values, it's best to run load tests simulating real traffic.
@@ -43,7 +43,7 @@ Also, [some bugs only happen when using musl](https://github.com/php/php-src/iss
4343

4444
In production environments, we recommend using FrankenPHP linked against glibc, compiled with an appropriate optimization level.
4545

46-
This can be achieved by using the Debian Docker images, using our maintainers [.deb](https://debs.henderkes.com) or [.rpm](https://rpms.henderkes.com) packages, or by [compiling FrankenPHP from sources](compile.md).
46+
This can be achieved by using the Debian Docker images, using [our maintainers .deb, .rpm, or .apk packages](https://pkgs.henderkes.com), or by [compiling FrankenPHP from sources](compile.md).
4747

4848
## Go Runtime Configuration
4949

@@ -146,7 +146,7 @@ All usual PHP-related performance optimizations apply with FrankenPHP.
146146

147147
In particular:
148148

149-
- check that [OPcache](https://www.php.net/manual/en/book.opcache.php) is installed, enabled and properly configured
149+
- check that [OPcache](https://www.php.net/manual/en/book.opcache.php) is installed, enabled, and properly configured
150150
- enable [Composer autoloader optimizations](https://getcomposer.org/doc/articles/autoloader-optimization.md)
151151
- ensure that the `realpath` cache is big enough for the needs of your application
152152
- use [preloading](https://www.php.net/manual/en/opcache.preloading.php)

install.sh

Lines changed: 41 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@
33
set -e
44

55
SUDO=""
6-
if [ "$(id -u)" -ne 0 ]; then
7-
SUDO="sudo"
8-
fi
96

107
if [ -z "${BIN_DIR}" ]; then
118
BIN_DIR=$(pwd)
@@ -34,12 +31,13 @@ Linux*)
3431
if [ "${ARCH}" = "aarch64" ] || [ "${ARCH}" = "x86_64" ]; then
3532
if command -v dnf >/dev/null 2>&1; then
3633
echo "📦 Detected dnf. Installing FrankenPHP from RPM repository..."
37-
if [ -n "${SUDO}" ]; then
34+
if [ "$(id -u)" -ne 0 ]; then
35+
SUDO="sudo"
3836
echo "❗ Enter your password to grant sudo powers for package installation"
3937
${SUDO} -v || true
4038
fi
41-
${SUDO} dnf -y install https://rpm.henderkes.com/static-php-1-0.noarch.rpm
42-
${SUDO} dnf -y module enable php-zts:static-8.4 || true
39+
${SUDO} dnf -y install https://rpm.henderkes.com/static-php-1-1.noarch.rpm
40+
${SUDO} dnf -y module enable php-zts:static-8.5 || true
4341
${SUDO} dnf -y install frankenphp
4442
echo
4543
echo "🥳 FrankenPHP installed to ${italic}/usr/bin/frankenphp${normal} successfully."
@@ -50,24 +48,50 @@ Linux*)
5048
exit 0
5149
fi
5250

53-
if command -v apt >/dev/null 2>&1 || command -v apt-get >/dev/null 2>&1; then
54-
echo "📦 Detected apt. Installing FrankenPHP from DEB repository..."
55-
if [ -n "${SUDO}" ]; then
51+
if command -v apt-get >/dev/null 2>&1; then
52+
echo "📦 Detected apt-get. Installing FrankenPHP from DEB repository..."
53+
if [ "$(id -u)" -ne 0 ]; then
54+
SUDO="sudo"
55+
echo "❗ Enter your password to grant sudo powers for package installation"
56+
${SUDO} -v || true
57+
fi
58+
${SUDO} sh -c 'curl -fsSL https://pkg.henderkes.com/api/packages/85/debian/repository.key -o /etc/apt/keyrings/static-php85.asc'
59+
${SUDO} sh -c 'echo "deb [signed-by=/etc/apt/keyrings/static-php85.asc] https://pkg.henderkes.com/api/packages/85/debian php-zts main" | sudo tee -a /etc/apt/sources.list.d/static-php85.list'
60+
${SUDO} apt-get update
61+
${SUDO} apt-get -y install frankenphp
62+
echo
63+
echo "🥳 FrankenPHP installed to ${italic}/usr/bin/frankenphp${normal} successfully."
64+
echo "❗ The systemd service uses the Caddyfile in ${italic}/etc/frankenphp/Caddyfile${normal}"
65+
echo "❗ Your php.ini is found in ${italic}/etc/php-zts/php.ini${normal}"
66+
echo
67+
echo "⭐ If you like FrankenPHP, please give it a star on GitHub: ${italic}https://github.com/php/frankenphp${normal}"
68+
exit 0
69+
fi
70+
71+
if command -v apk >/dev/null 2>&1; then
72+
echo "📦 Detected apk. Installing FrankenPHP from APK repository..."
73+
if [ "$(id -u)" -ne 0 ]; then
74+
SUDO="sudo"
5675
echo "❗ Enter your password to grant sudo powers for package installation"
5776
${SUDO} -v || true
5877
fi
59-
${SUDO} sh -c 'curl -fsSL https://key.henderkes.com/static-php.gpg -o /usr/share/keyrings/static-php.gpg'
60-
${SUDO} sh -c 'echo "deb [signed-by=/usr/share/keyrings/static-php.gpg] https://deb.henderkes.com/ stable main" > /etc/apt/sources.list.d/static-php.list'
61-
if command -v apt >/dev/null 2>&1; then
62-
${SUDO} apt update
63-
${SUDO} apt -y install frankenphp
78+
79+
KEY_URL="https://pkg.henderkes.com/api/packages/85/alpine/key"
80+
${SUDO} sh -c "cd /etc/apk/keys && curl -JOsS \"$KEY_URL\" 2>/dev/null || true"
81+
82+
REPO_URL="https://pkg.henderkes.com/api/packages/85/alpine/main/php-zts"
83+
if grep -q "$REPO_URL" /etc/apk/repositories 2>/dev/null; then
84+
echo "Repository already exists in /etc/apk/repositories"
6485
else
65-
${SUDO} apt-get update
66-
${SUDO} apt-get -y install frankenphp
86+
${SUDO} sh -c "echo \"$REPO_URL\" >> /etc/apk/repositories"
87+
${SUDO} apk update
88+
echo "Repository added to /etc/apk/repositories"
6789
fi
90+
91+
${SUDO} apk add frankenphp
6892
echo
6993
echo "🥳 FrankenPHP installed to ${italic}/usr/bin/frankenphp${normal} successfully."
70-
echo "❗ The systemd service uses the Caddyfile in ${italic}/etc/frankenphp/Caddyfile${normal}"
94+
echo "❗ The OpenRC service uses the Caddyfile in ${italic}/etc/frankenphp/Caddyfile${normal}"
7195
echo "❗ Your php.ini is found in ${italic}/etc/php-zts/php.ini${normal}"
7296
echo
7397
echo "⭐ If you like FrankenPHP, please give it a star on GitHub: ${italic}https://github.com/php/frankenphp${normal}"

package/alpine/frankenphp.openrc

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/sbin/openrc-run
2+
3+
name="FrankenPHP"
4+
description="The modern PHP app server"
5+
6+
command="/usr/bin/frankenphp"
7+
command_args="run --environ --config /etc/frankenphp/Caddyfile"
8+
command_user="frankenphp:frankenphp"
9+
command_background="yes"
10+
capabilities="^cap_net_bind_service"
11+
pidfile="/run/frankenphp/frankenphp.pid"
12+
start_stop_daemon_args="--chdir /var/lib/frankenphp"
13+
14+
depend() {
15+
need net
16+
after firewall
17+
}
18+
19+
start_pre() {
20+
checkpath --directory --owner frankenphp:frankenphp --mode 0755 /run/frankenphp
21+
22+
$command validate --config /etc/frankenphp/Caddyfile
23+
}
24+
25+
reload() {
26+
ebegin "Reloading $name configuration"
27+
$command reload --config /etc/frankenphp/Caddyfile --force
28+
eend $?
29+
}

package/alpine/post-deinstall.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/sh
2+
3+
if getent passwd frankenphp >/dev/null; then
4+
deluser frankenphp
5+
fi
6+
7+
if getent group frankenphp >/dev/null; then
8+
delgroup frankenphp
9+
fi
10+
11+
rmdir /var/lib/frankenphp 2>/dev/null || true
12+
13+
exit 0

package/alpine/post-install.sh

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/bin/sh
2+
3+
if ! getent group frankenphp >/dev/null; then
4+
addgroup -S frankenphp
5+
fi
6+
7+
if ! getent passwd frankenphp >/dev/null; then
8+
adduser -S -h /var/lib/frankenphp -s /sbin/nologin -G frankenphp -g "FrankenPHP web server" frankenphp
9+
fi
10+
11+
chown -R frankenphp:frankenphp /var/lib/frankenphp
12+
chmod 755 /var/lib/frankenphp
13+
14+
# allow binding to privileged ports
15+
if command -v setcap >/dev/null 2>&1; then
16+
setcap cap_net_bind_service=+ep /usr/bin/frankenphp || true
17+
fi
18+
19+
# check if 0.0.0.0:2019 or 127.0.0.1:2019 are in use
20+
port_in_use() {
21+
port_hex=$(printf '%04X' "$1")
22+
grep -qE "(00000000|0100007F):${port_hex}" /proc/net/tcp 2>/dev/null
23+
}
24+
25+
# trust frankenphp certificates if the admin api can start
26+
if [ -x /usr/bin/frankenphp ]; then
27+
if ! port_in_use 2019; then
28+
HOME=/var/lib/frankenphp /usr/bin/frankenphp run >/dev/null 2>&1 &
29+
FRANKENPHP_PID=$!
30+
sleep 2
31+
HOME=/var/lib/frankenphp /usr/bin/frankenphp trust || true
32+
kill -TERM $FRANKENPHP_PID 2>/dev/null || true
33+
34+
chown -R frankenphp:frankenphp /var/lib/frankenphp
35+
fi
36+
fi
37+
38+
if command -v rc-update >/dev/null 2>&1; then
39+
rc-update add frankenphp default
40+
rc-service frankenphp start
41+
fi
42+
43+
exit 0

package/alpine/pre-deinstall.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/sh
2+
3+
if command -v rc-service >/dev/null 2>&1; then
4+
rc-service frankenphp stop || true
5+
fi
6+
7+
if command -v rc-update >/dev/null 2>&1; then
8+
rc-update del frankenphp default || true
9+
fi
10+
11+
exit 0

package/debian/frankenphp.service

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[Unit]
2-
Description=FrankenPHP
2+
Description=FrankenPHP - The modern PHP app server
33
Documentation=https://frankenphp.dev/docs/
44
After=network.target network-online.target
55
Requires=network-online.target
@@ -8,12 +8,15 @@ Requires=network-online.target
88
Type=notify
99
User=frankenphp
1010
Group=frankenphp
11+
ExecStartPre=/usr/bin/frankenphp validate --config /etc/frankenphp/Caddyfile
1112
ExecStart=/usr/bin/frankenphp run --environ --config /etc/frankenphp/Caddyfile
12-
ExecReload=/usr/bin/frankenphp reload --config /etc/frankenphp/Caddyfile --force
13+
ExecReload=/usr/bin/frankenphp reload --config /etc/frankenphp/Caddyfile
14+
WorkingDirectory=/var/lib/frankenphp
1315
TimeoutStopSec=5s
1416
LimitNOFILE=1048576
1517
LimitNPROC=512
1618
PrivateTmp=true
19+
ProtectHome=true
1720
ProtectSystem=full
1821
AmbientCapabilities=CAP_NET_BIND_SERVICE
1922

package/debian/postinst.sh

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,29 @@ if [ "$1" = "configure" ]; then
1919
usermod -aG www-data frankenphp
2020
fi
2121

22+
# trust frankenphp certificates before starting the systemd service
23+
if [ -z "$2" ] && [ -x /usr/bin/frankenphp ]; then
24+
HOME=/var/lib/frankenphp /usr/bin/frankenphp run --config /dev/null &
25+
FRANKENPHP_PID=$!
26+
sleep 2
27+
HOME=/var/lib/frankenphp /usr/bin/frankenphp trust || true
28+
kill "$FRANKENPHP_PID" || true
29+
wait "$FRANKENPHP_PID" 2>/dev/null || true
30+
31+
chown -R frankenphp:frankenphp /var/lib/frankenphp
32+
fi
33+
2234
# Handle cases where package was installed and then purged;
2335
# user and group will still exist but with no home dir
2436
if [ ! -d /var/lib/frankenphp ]; then
2537
mkdir -p /var/lib/frankenphp
26-
chown frankenphp:frankenphp /var/lib/frankenphp
38+
chown -R frankenphp:frankenphp /var/lib/frankenphp
2739
fi
2840

2941
# Add log directory with correct permissions
3042
if [ ! -d /var/log/frankenphp ]; then
3143
mkdir -p /var/log/frankenphp
32-
chown frankenphp:frankenphp /var/log/frankenphp
44+
chown -R frankenphp:frankenphp /var/log/frankenphp
3345
fi
3446
fi
3547

@@ -61,11 +73,3 @@ fi
6173
if command -v setcap >/dev/null 2>&1; then
6274
setcap cap_net_bind_service=+ep /usr/bin/frankenphp || true
6375
fi
64-
65-
if [ -x /usr/bin/frankenphp ]; then
66-
HOME=/var/lib/frankenphp /usr/bin/frankenphp run --config /dev/null &
67-
FRANKENPHP_PID=$!
68-
HOME=/var/lib/frankenphp /usr/bin/frankenphp trust || true
69-
kill "$FRANKENPHP_PID" || true
70-
wait "$FRANKENPHP_PID" 2>/dev/null || true
71-
fi

package/rhel/frankenphp.service

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
[Unit]
2-
Description=FrankenPHP server
3-
After=network.target
2+
Description=FrankenPHP - The modern PHP app server
3+
Documentation=https://frankenphp.dev/docs/
4+
After=network.target network-online.target
5+
Requires=network-online.target
46

57
[Service]
68
Type=notify

0 commit comments

Comments
 (0)