How to Restart PHP-FPM in Ubuntu

The FastCGI Reinitialization Vector

When running a modern Nginx web server on Ubuntu, PHP processing is not handled internally by the web server (as it was in legacy Apache setups). It is outsourced to an independent, highly efficient background daemon known as PHP-FPM (FastCGI Process Manager). If you modify the core `php.ini` configuration file (e.g., increasing the `memory_limit` or `upload_max_filesize`), the active PHP-FPM worker threads mathematically ignore the changes. You must execute a targeted administrative interrupt, commanding the Linux kernel to cleanly terminate and respawn the FPM daemon to inject the new parameters into active RAM.

How to Restart PHP-FPM in Ubuntu

Modern Ubuntu environments manage the PHP-FPM daemon via the `systemctl` utility. However, the exact syntax of the command requires mathematical precision because the service name changes depending on the specific version of PHP currently installed on the silicon.

1. Open your terminal application or connect to the server via SSH.
2. The Version Interrogation (Mandatory Step):
* You cannot simply type `restart php-fpm`. You must know the exact version number running on the machine (e.g., 7.4, 8.1, 8.3).
* Type exactly:
php -v
* Press Enter.
* The terminal will output the active version (e.g., `PHP 8.2.14`). Note the primary and secondary version numbers (in this case, 8.2).
3. The Execution Command (`systemctl restart`):
* You must construct the command using the version number extracted in the previous step.
* Assume the version is 8.2.
* Type exactly:
sudo systemctl restart php8.2-fpm
* Press Enter and supply your cryptographic `sudo` password.
* Note: If you want to avoid dropping active user connections (a “graceful” restart), substitute `restart` with `reload` (e.g., `sudo systemctl reload php8.2-fpm`).
4. The Diagnostic Verification Protocol:
* Never blindly assume the daemon respawned successfully. A syntax error in your `php.ini` file will cause a catastrophic failure during the boot sequence, taking your entire web application offline (returning a 502 Bad Gateway error).
* Type exactly:
sudo systemctl status php8.2-fpm
* Press Enter.
* Look closely at the output matrix. You must see the line Active: active (running) displayed in green text. This mathematically confirms the FastCGI process manager has successfully reinitialized and is actively accepting requests from Nginx.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.