Developer tool
Nginx + PHP-FPM Generator
Generate Nginx server snippets that pass PHP to PHP-FPM over a Unix socket or TCP upstream.
How it works
What it does
The Nginx PHP Generator produces server/location fragments that forward PHP requests to PHP-FPM via a Unix socket or TCP upstream. It validates upstream target shapes so you do not accidentally emit open-ended proxy configurations.
When to use it
- Creating a new site block for a PHP app
- Switching from Apache to Nginx fronting FPM
- Aligning Docker Compose service names with fastcgi_pass
How input is processed safely
Inputs are limited fields (mode, socket/host patterns, root path text). The tool returns Nginx configuration text only—it does not reload Nginx here and does not expose other tenants’ sockets.
Examples
- Unix socket:
fastcgi_pass unix:/run/php/php-fpm.sock; - TCP upstream to an internal FPM service
- PHP front-controller try_files pattern
Common mistakes
- Passing arbitrary remote upstreams without network policy
- Wrong SCRIPT_FILENAME fastcgi params
- Leaving server tokens/path disclosure misconfigured elsewhere
Nginx does not run PHP itself; it forwards matching requests to FPM. Correct try_files, SCRIPT_FILENAME, and security location blocks for hidden files are as important as the fastcgi_pass line.
Upstream targets are validated to reduce foot-guns, but you still must place the snippet in a full server block with TLS, logs, and root path settings appropriate to your deployment. Test with nginx -t and a real PHP file that calls phpinfo only on private staging.
When using TCP upstreams across hosts, restrict network access so the FPM port is not reachable from the public internet. Prefer sockets on single-host setups.
Practical tips
- Keep inputs small and representative; huge pastes slow feedback and raise risk of accidental secret disclosure.
- After using Nginx + PHP-FPM Generator, verify the result in your own environment (correct SAPI, correct host, correct project root).
- Cross-link findings to ZendStudio.net PHP error guides and IDE setup pages when the next step is configuration rather than code edits.
- Prefer repeatable project tooling (CI, Composer scripts, IDE inspections) for repo-wide enforcement; this page is for interactive problem-solving.
Privacy note
Config snippets may include internal hostnames. Treat them as infrastructure-sensitive and avoid publishing production topology unnecessarily.
Run in browser
AJAX processing only. No remote PHP execution sandbox. Results are not indexed.
Safety notes
- Submitted tool contents are not written to analytics or search logs.
- This site never evaluates arbitrary PHP from the browser.
- Generated configs are starting points—validate on a staging host before production.