PHP-FPM

使用 PHP-FPM 執行 PHP 應用,同時由 Fluxheim 提供靜態資源並安全轉發 PHP request。

外部 PHP-FPM pool

[vhosts.php]
enabled = true
root = "/srv/app/public"
index = "index.php"

[vhosts.php.fpm]
mode = "external"
socket = "/run/php-fpm/app.sock"

Endpoint 選擇

模式在以下情況使用
socketFluxheim 和 PHP-FPM 在同一 host 上執行。
tcpPHP-FPM runs in another container or host.
tcp_upstreams你需要在 PHP-FPM pools 之間做簡單 safe-method failover。
managedFluxheim 應啟動並 supervision 一個私有 PHP-FPM master。

Managed PHP-FPM

[vhosts.php.fpm]
mode = "managed"
php_fpm_binary = "/usr/sbin/php-fpm"
socket_dir = "/run/fluxheim/php"
workers = 4
process_manager = "dynamic"
start_servers = 2
min_spare_servers = 1
max_spare_servers = 4

Managed mode lets Fluxheim start a private php-fpm master for the vhost. Use it when you want Fluxheim to own the socket and generated pool files.

PHP 安全控制

  • 將 PHP 檔案保持在設定的 root 內。
  • 儘可能直接提供靜態資源。
  • PHP 執行失敗時絕不要暴露 PHP 原始碼。
  • 禁止在 upload directories 中執行 PHP。
  • 對不受信任的應用使用 request 和 response byte limits。
繁體中文