The website still runs the old PHP after you installed a newer PHP-FPM
phpinfo() in the browser reports an older PHP Version than php -vShort answer
With PHP-FPM, the web server hands each .php request to a pool, and the pool belongs to one PHP version. Installing a new version changes php -v, not the pool the site talks to. Change the address in fastcgi_pass (nginx) or SetHandler (Apache), validate the config, and reload.
Fix it fast
1Find out which cause you have
Ask the web server itself. A throw-away file prints the version and the interface that served it. The word fpm-fcgi means a PHP-FPM pool answered, and apache2handler would mean Apache's own module instead.
# put the file in the document root of the affected site echo '<?php echo PHP_VERSION, " ", PHP_SAPI;' | sudo tee /var/www/example.com/public/whoami.php curl -s https://example.com/whoami.php php -v | head -n 1 sudo rm /var/www/example.com/public/whoami.php2Match what you see, then jump to its fix
- 1
The first-step output ends in fpm-fcgi with the old version, and the site's nginx config has a fastcgi_pass line.nginx passes the request to the pool of the old versionFix - 2
The version is old, PHP_SAPI is fpm-fcgi, and the Apache config has a SetHandler line that begins with proxy:unix or proxy:fcgi.Apache hands .php files to the old pool through mod_proxy_fcgiFix - 3
You edited fastcgi_pass, nothing changed, and the config test prints an error or you forgot to reload.The new setting never took effect because nginx kept the old configurationFix
- 1
What does the error look like?
phpinfo() in the browser reports an older PHP Version than php -vPHP_SAPI prints fpm-fcgi and the version is not the one you installed last
Cause 1 of 3
nginx passes the request to the pool of the old version
1Check
fastcgi_pass sets the address of the FastCGI server, either host:port or a unix: socket path. Each version has its own pool with its own listen address, and different location or server blocks can name different ones. See which address your site uses and which sockets exist.
grep -rn "fastcgi_pass" /etc/nginx/
sudo ss -xlp | grep -i php2Fix
Change fastcgi_pass to the listen address of the pool that belongs to the version you want. The pool's own config file shows that value in its listen directive.
location ~ \.php$ {
# keep the other lines of your existing block
fastcgi_pass unix:/path/from/the/new/pool/listen/directive.sock;
}3Verify
Test the config, reload nginx, and request the file again.
sudo nginx -t && sudo systemctl reload nginx
curl -s https://example.com/whoami.phpConfirmed by nginx.org
Cause 2 of 3
Apache hands .php files to the old pool through mod_proxy_fcgi
1Check
With PHP-FPM, Apache needs mod_proxy and mod_proxy_fcgi, and a SetHandler line names the pool socket. A leftover line from the previous version keeps pointing at the old one.
grep -rn "proxy:unix\|proxy:fcgi" /etc/apache2/
apache2ctl -M | grep -i proxy2Fix
Replace the socket in the SetHandler line with the listen address of the new version's pool, keeping the rest of the line as it is.
<FilesMatch "\.php$">
SetHandler "proxy:unix:/path/from/the/new/pool/listen/directive.sock|fcgi://localhost/"
</FilesMatch>3Verify
Test the Apache config, reload it, and request the test file again.
sudo apache2ctl configtest && sudo systemctl reload apache2
curl -s https://example.com/whoami.phpConfirmed by httpd.apache.org
Cause 3 of 3
The new setting never took effect because nginx kept the old configuration
1Check
nginx reads its configuration again only when it is told to. If the new configuration cannot be applied, it carries on with the old one, so the old pool keeps answering. Run the test and read its last lines.
sudo nginx -t2Fix
Fix whatever the test reports, then reload so the master process applies the new file.
sudo nginx -t
sudo systemctl reload nginx3Verify
The test output ends in a success line, and the test file shows the new version.
curl -s https://example.com/whoami.phpConfirmed by nginx.org
How do I stop it coming back?
- After each PHP upgrade, request a whoami.php-style file through the web server and compare it with php -v.
- Keep one fastcgi_pass or SetHandler address per site, in one included file, so there is a single line to change.
- Remove the old PHP-FPM version once no site uses it, so a stale address fails loudly instead of answering quietly.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
- TaxiDexMy own multi-tenant taxi dispatch SaaS: API, dispatcher portal, driver and passenger apps, and the servers underneath.
- stegnor.comMy company site: 804 pages from a Python and Jinja generator, with 15 free browser tools.
- Spotless LaundryAn on-demand laundry app: Flutter on a Laravel back end, with Firebase for live updates.
Related fixes
Servers
Apache and the command line run different PHP versions
a2enmod php8.3 succeeds but php -v still shows the old version
Apache and the php command are two separate things.
2 causes, each with a fixServers
nginx cannot open the PHP-FPM socket: Permission denied
502 Bad Gateway
nginx runs as one user and PHP-FPM creates its socket for another.
3 causes, each with a fixServers
nginx gives up waiting for the app and returns 504
upstream timed out (110: Connection timed out) while reading response header from upstream
nginx returns 504 when the app behind it takes the request but sends nothing back within proxy_read_timeout (60 seconds by default), or when the connection cannot be opened in time.
5 causes, each with a fixServers
nginx and PHP-FPM show File not found or Primary script unknown
File not found.
PHP-FPM received a script path it could not turn into a file.
4 causes, each with a fixServers
nginx still returns 504 although the PHP script has a long time limit
upstream timed out (110: Connection timed out) while reading response header from upstream
set_time_limit() only controls PHP.
4 causes, each with a fixServers
Cookies from a PHP backend vanish behind an nginx proxy
Login works when you call the backend directly but fails through nginx
nginx forwards Set-Cookie headers from the backend unchanged, so lost cookies usually come from the cookie itself: a domain or path that does not match the public URL, or Secure and SameSite flags the browser rejects.
4 causes, each with a fix