Fluxheim/文件/WordPress

WordPress

適用於普通 WordPress 前端控制器的實用 PHP-FPM 配方。

WordPress 虛擬主機

[[vhosts]]
name = "wordpress"
hosts = ["blog.example.com"]

[vhosts.web]
root = "/srv/wordpress"
index_files = ["index.php", "index.html"]
deny_dotfiles = true

[vhosts.php]
enabled = true
root = "/srv/wordpress"
index = "index.php"
preset = "wordpress"
try_files = "wordpress"
deny_path_prefixes = ["/wp-content/uploads/"]

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

WordPress cache route

[[vhosts.routes]]
name = "wp-assets"
path_prefix = "/wp-content/"
action = "proxy"

[vhosts.routes.proxy]
upstreams = ["127.0.0.1:9000"]

[vhosts.routes.cache]
enabled = true
preset = "wordpress"
status_ttls = { "200" = 3600, "404" = 60 }
extensions = ["css", "js", "png", "jpg", "webp", "svg"]
bypass_cookie_name_prefixes = ["wordpress_logged_in_", "wordpress_sec_"]

常用檢查

  • 確保 PHP-FPM 使用者可以讀取 WordPress 檔案。
  • 僅在 WordPress 需要寫入的地方保持上傳可寫入。
  • Put cache in front of public assets, not wp-admin.
  • Keep login, preview, cron, XML-RPC, and admin paths out of shared cache.
  • 使用 WordPress 預設作為基準,然後新增特定於網站的旁路。

很合身

呢個設定適合一般 WordPress front controller:Fluxheim 安全噉提供 static file、喺 upload path 阻擋 PHP,再將 dynamic request 轉去 PHP-FPM。

粵語