Nginx + PHP-FPM Configuration

Running PHP behind Nginx with PHP-FPM is the standard production setup for WordPress, Laravel, and Symfony apps. Our generator wires up fastcgi_pass correctly so you can focus on your application.

Passing PHP to FPM

Route .php requests to the FPM socket with fastcgi_pass and include fastcgi_params. Use a location that only matches real PHP entry points.

location ~ \.php$ {
    include snippets/fastcgi-php.conf;
    fastcgi_pass unix:/run/php/php8.4-fpm.sock;
}

Framework presets

WordPress, Laravel, Symfony and Drupal each need a different front-controller rule. The generator ships presets so you do not expose stray PHP files or uploads directories that can execute code.

Open the PHP-FPM generator

Frequently asked questions

Socket or TCP for PHP-FPM?

A Unix socket is faster and avoids opening a port; use TCP only when FPM runs on another host or in a container.

Why do I get 502 Bad Gateway with PHP-FPM?

Usually the socket path in fastcgi_pass does not match the pool, or the nginx user is not allowed to connect to it. Check the FPM pool listen and listen.owner settings.

Guides