WordPress
Một công thức PHP-FPM thực tế cho bộ điều khiển phía trước WordPress thông thường.
vhost 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_"]
Kiểm tra thường dùng
- Đảm bảo người dùng PHP-FPM có thể đọc các tệp WordPress.
- Giữ cho nội dung tải lên chỉ có thể ghi ở những nơi WordPress cần ghi.
- Put cache in front of public assets, not wp-admin.
- Keep login, preview, cron, XML-RPC, and admin paths out of shared cache.
- Sử dụng cài đặt trước của WordPress làm đường cơ sở, sau đó thêm các đường vòng dành riêng cho trang web.
Phù hợp tốt
Thiết lập này dành cho WordPress front controller thông thường: Fluxheim phục vụ static file an toàn, chặn PHP trong upload path và chuyển dynamic request đến PHP-FPM.