Skip to main content
Version: 7.x

Avoid PHP-FPM Reloading

Deployer symlinks current to latest release dir.

current -> releases/3/
releases/
1/
2/
3/

The problem

PHP Opcodes gets cached. And if SCRIPT_FILENAME contains current symlink, on new deploy nothing updates. Usually solution is simple to reload php-fpm after deploy, but such reload can lead to dropped or failed requests. Correct fix, is to configure your server set SCRIPT_FILENAME to resolved path. You can check your server configuration by printing SCRIPT_FILENAME.

echo $_SERVER['SCRIPT_FILENAME'];

If it prints something like /home/deployer/example.com/current/index.php with current in path, your server configured incorrectly.

Fix for Nginx

Nginx has special variable $realpath_root, use it to set up SCRIPT_FILENAME:

location ~ \.php$ {
include fastcgi_params;
fastcgi_pass unix:/var/run/php/php-fpm.sock;
- fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
+ fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
}

Fix for Caddy

tip

If you're already using servers provisioned by Deployer, you don't need to fix anything, as everything already configured properly.

Use resolve_root_symlink:

php_fastcgi * unix//run/php/php-fpm.sock {
resolve_root_symlink
}


Support Deployer โค๏ธ

Hello, my name is Anton Medvedev (@antonmedv). I'm the creator of the Deployer. I maintain this open source project in my spare time. Supporters on GitHub give me extra motivation to work on the project.

Consider supporting Deployer via GitHub Sponsors.

Also, please, nominate me for GitHub Stars award. Thanks!