Why are my 2 sites on the same server (randomly?) switching PHP versions with PHP-FPM - Hack The Tech - Latest News related to Computer and Technology

Hack The Tech - Latest News related to Computer and Technology

Get Daily Latest News related to Computer and Technology and hack the world.

Thursday, August 18, 2022

Why are my 2 sites on the same server (randomly?) switching PHP versions with PHP-FPM

My issue is as follows:

1 server running Debian 11 (though I've tested with 9 and 10 and they both show the same behaviour) with 2 websites both configured to run with php-fpm & apache. Each site has a single index.php file and the contents of those files is <?php phpinfo(); ?>. 1 site has been set to run php8.0 and the other php8.1. This has been set up by including an apache config file into my main apache config file for each site with the contents:

<IfModule proxy_fcgi_module>
# Enable http authorization headers
<IfModule setenvif_module>
SetEnvIfNoCase ^Authorization$ "(.+)" HTTP_AUTHORIZATION=$1
</IfModule>

<FilesMatch ".+\.ph(ar|p|tml)$">
    <If "-f %{REQUEST_FILENAME}">
        SetHandler "proxy:unix:/run/php/php8.0-fpm.sock|fcgi://localhost"
    </If>
</FilesMatch>
<FilesMatch ".+\.(phps|inc)$">
    # Deny access to raw php sources by default
    # To re-enable it's recommended to enable access to the files
    # only in specific virtual host or directory
    Require all denied
</FilesMatch>
# Deny access to files without filename (e.g. '.php')
<FilesMatch "^\.ph(ar|p|ps|tml)$">
    Require all denied
</FilesMatch>

The config file for php8.1 then uses the php8.1-fpm.sock. ps aux shows the following:

root      114787  0.0  0.3 222780 27312 ?        Ss   17:10   0:00 php-fpm: master process (/etc/php/8.0/fpm/php-fpm.conf)
www-data  114788  0.0  0.5 247140 48664 ?        S    17:10   0:03 php-fpm: pool www
www-data  114789  0.0  0.5 247128 48592 ?        S    17:10   0:03 php-fpm: pool www
www-data  114790  0.0  0.6 247136 48748 ?        S    17:10   0:03 php-fpm: pool www
www-data  114791  0.0  0.5 247128 48676 ?        S    17:10   0:05 php-fpm: pool www
www-data  114792  0.0  0.5 247132 48548 ?        S    17:10   0:04 php-fpm: pool www
root      114802  0.0  0.3 227196 28120 ?        Ss   17:10   0:00 php-fpm: master process (/etc/php/8.1/fpm/php-fpm.conf)
www-data  114803  0.0  0.3 227764 26744 ?        S    17:10   0:00 php-fpm: pool www
www-data  114804  0.0  0.1 227196  8896 ?        S    17:10   0:00 php-fpm: pool www
www-data  114805  0.0  0.1 227196  8896 ?        S    17:10   0:00 php-fpm: pool www
www-data  114806  0.0  0.1 227196  8896 ?        S    17:10   0:00 php-fpm: pool www

What I really don't understand is why when I keep refreshing the individual pages do I sometimes see the 8.0 site showing that it is using php8.1 and vice versa. I sometimes have to refresh the pages 10-20 times before it switches but it never fails to show up sooner rather than later.

How would I go about figuring out why this is happening, or is there something very obvious that I'm missing?

Many thanks in advance!



source https://stackoverflow.com/questions/73393094/why-are-my-2-sites-on-the-same-server-randomly-switching-php-versions-with-ph

No comments:

Post a Comment