Php-fpm, 4 versions running, seriously?

My YunoHost server

Hardware: Raspberry Pi 3B+ at home
YunoHost version: 11.2.4
I have access to my server : Through SSH | direct access via keyboard / screen |
Are you in a special context or did you perform some particular tweaking on your YunoHost instance ? : no

Description of my issue

I am wondering if this is a normal situation to have 4 versions of php-fpm service running at the same time on my server: 7.4, 8.0, 8.1 and 8.2

:thinking:

$ sudo systemctl status php7.4-fpm.service                                                                                                                                                         
● php7.4-fpm.service - The PHP 7.4 FastCGI Process Manager
     Loaded: loaded (/lib/systemd/system/php7.4-fpm.service; enabled; vendor preset: enabled)                                                                                                                     
     Active: active (running) since Sun 2023-09-24 20:17:21 CEST; 14h ago
       Docs: man:php-fpm7.4(8)                                                                                                                                                                                    
    Process: 994 ExecStartPost=/usr/lib/php/php-fpm-socket-helper install /run/php/php-fpm.sock /etc/php/7.4/fpm/pool.d/www.conf 74 (code=exited, status=0/SUCCESS)                                               
   Main PID: 504 (php-fpm7.4)                                                                                                                                                                                     
     Status: "Processes active: 0, idle: 2, Requests: 0, slow: 0, Traffic: 0req/sec"                                                                                                                              
      Tasks: 3 (limit: 793)                                                                                                                                                                                       
        CPU: 7.329s                                                                                                                                                                                               
     CGroup: /system.slice/php7.4-fpm.service                                                                                                                                                                     
             ├─504 php-fpm: master process (/etc/php/7.4/fpm/php-fpm.conf)                                                                                                                                        
             ├─992 php-fpm: pool www                                                                                                                                                                              
             └─993 php-fpm: pool www                                                                                                                                                                              
                                                                                                                                                                                                                  
Sep 24 20:17:09 myServer.fr systemd[1]: Starting The PHP 7.4 FastCGI Process Manager...                                                                                                                              
Sep 24 20:17:21 myServer.fr systemd[1]: Started The PHP 7.4 FastCGI Process Manager.                                                                                                                                 
myUser@myServer:~$ sudo systemctl status php8.0-fpm.service 
● php8.0-fpm.service - The PHP 8.0 FastCGI Process Manager
     Loaded: loaded (/lib/systemd/system/php8.0-fpm.service; enabled; vendor preset: enabled)                                                                                                                     
     Active: active (running) since Sun 2023-09-24 20:17:21 CEST; 14h ago
       Docs: man:php-fpm8.0(8)                                                                                                                                                                                    
    Process: 989 ExecStartPost=/usr/lib/php/php-fpm-socket-helper install /run/php/php-fpm.sock /etc/php/8.0/fpm/pool.d/www.conf 80 (code=exited, status=0/SUCCESS)                                               
   Main PID: 506 (php-fpm8.0)                                                                                                                                                                                     
     Status: "Processes active: 0, idle: 2, Requests: 45, slow: 0, Traffic: 0req/sec"                                                                                                                             
      Tasks: 3 (limit: 793)                                                                                                                                                                                       
        CPU: 10.325s                                                                                                                                                                                              
     CGroup: /system.slice/php8.0-fpm.service                                                                                                                                                                     
             ├─506 php-fpm: master process (/etc/php/8.0/fpm/php-fpm.conf)                                                                                                                                        
             ├─986 php-fpm: pool www                                                                                                                                                                              
             └─988 php-fpm: pool www                                                                                                                                                                              
                                                                                                                                                                                                                  
Sep 24 20:17:09 myServer.fr systemd[1]: Starting The PHP 8.0 FastCGI Process Manager...                                                                                                                              
Sep 24 20:17:21 myServer.fr systemd[1]: Started The PHP 8.0 FastCGI Process Manager.                                                                                                                                 
myUser@myServer:~$ sudo systemctl status php8.1-fpm.service 
● php8.1-fpm.service - The PHP 8.1 FastCGI Process Manager
     Loaded: loaded (/lib/systemd/system/php8.1-fpm.service; enabled; vendor preset: enabled)                                                                                                                     
     Active: active (running) since Sun 2023-09-24 20:17:22 CEST; 14h ago
       Docs: man:php-fpm8.1(8)                                                                                                                                                                                    
    Process: 1155 ExecStartPost=/usr/lib/php/php-fpm-socket-helper install /run/php/php-fpm.sock /etc/php/8.1/fpm/pool.d/www.conf 81 (code=exited, status=0/SUCCESS)                                              
   Main PID: 508 (php-fpm8.1)                                                                                                                                                                                     
     Status: "Processes active: 0, idle: 8, Requests: 8043, slow: 0, Traffic: 0req/sec"                                                                                                                           
      Tasks: 9 (limit: 793)                                                                                                                                                                                       
        CPU: 30min 54.252s                                                                                                                                                                                        
     CGroup: /system.slice/php8.1-fpm.service                                                                                                                                                                     
             ├─  508 php-fpm: master process (/etc/php/8.1/fpm/php-fpm.conf)                                                                                                                                      
             ├─ 1151 php-fpm: pool www                                                                                                                                                                            
             ├─ 1154 php-fpm: pool www                                                                                                                                                                            
             ├─ 7737 php-fpm: pool nextcloud                                                                                                                                                                      
             ├─ 8361 php-fpm: pool nextcloud                                                                                                                                                                      
             ├─12342 php-fpm: pool nextcloud                                                                                                                                                                      
             ├─12362 php-fpm: pool nextcloud                                                                                                                                                                      
             ├─14993 php-fpm: pool nextcloud                                                                                                                                                                      
             └─16271 php-fpm: pool nextcloud                                                                                                                                                                      
                                                                                                                                                                                                                  
Sep 24 20:17:10 myServer.fr systemd[1]: Starting The PHP 8.1 FastCGI Process Manager...                                                                                                                              
Sep 24 20:17:22 myServer.fr systemd[1]: Started The PHP 8.1 FastCGI Process Manager.                                                                                                                                 
myUser@myServer:~$ sudo systemctl status php8.2-fpm.service 
● php8.2-fpm.service - The PHP 8.2 FastCGI Process Manager
     Loaded: loaded (/lib/systemd/system/php8.2-fpm.service; enabled; vendor preset: enabled)                                                                                                                     
     Active: active (running) since Sun 2023-09-24 20:17:21 CEST; 14h ago
       Docs: man:php-fpm8.2(8)                                                                                                                                                                                    
    Process: 1103 ExecStartPost=/usr/lib/php/php-fpm-socket-helper install /run/php/php-fpm.sock /etc/php/8.2/fpm/pool.d/www.conf 82 (code=exited, status=0/SUCCESS)                                              
   Main PID: 510 (php-fpm8.2)                                                                                                                                                                                     
     Status: "Processes active: 0, idle: 2, Requests: 19, slow: 0, Traffic: 0req/sec"                                                                                                                             
      Tasks: 3 (limit: 793)                                                                                                                                                                                       
        CPU: 12.165s                                                                                                                                                                                              
     CGroup: /system.slice/php8.2-fpm.service                                                                                                                                                                     
             ├─ 510 php-fpm: master process (/etc/php/8.2/fpm/php-fpm.conf)                                                                                                                                       
             ├─1101 php-fpm: pool www                                                                                                                                                                             
             └─1102 php-fpm: pool www                                                                                                                                                                             
                                                                                                                                                                                                                  
Sep 24 20:17:10 myServer.fr systemd[1]: Starting The PHP 8.2 FastCGI Process Manager...                                                                                                                              
Sep 24 20:17:21 myServer.fr systemd[1]: Started The PHP 8.2 FastCGI Process Manager.  

Depending on the apps you have installed, yes. :slight_smile: I see only Nextcloud? Do you have other PHP apps?

It’s quite possible YunoHost does not automatically cleanup unused PHP version. In any case, the unused services should have a minimal impact on the memory and CPU.

Php-fpm, 4 versions running, seriously?

We’re all ears if you have a better solution for the problems of “We’d like to stick as much as we can to Debian’s vanilla”, combined with “People want to have the latest top-notch version” combined with “Some software requires recent versions of PHP but some others are not forward-compatible with the recent versions” ¯\_(ツ)_/¯

2 Likes

I am running the following apps: Baikal, Jirafeau, Nextcloud, Shell In A Box, SnappyMail and Transmission.

@Aleks, this question is not a criticism, but a genuinely naive one. I just wanted to now if the situation is “normal”.

1 Like

All these apps run on PHP8.2-FPM. You may try to apt remove the other versions, if YunoHost lets you do so. Do not force it if it asks to.

2 Likes

You mean running?
sudo apt remove php7.4-fpm php8.0-fpm php8.1-fpm

Before that, you can try this command: ls /etc/php/**/fpm/pool.d/
It will lists app specific config files, and the version or php running it.

Yes. And as titus said, be careful and do not force it if it asks to :slight_smile:

1 Like

Be carefull, Nextcloud use php8.1-fpm not php8.2-fpm.
The command ls /etc/php/**/fpm/pool.d list also old versions of config file (example an old version of Nextcloud that was on an old yunohost with Debian 10 before migration to Debian 11 is not delete)
This command is more useful to see which versions to keep :

lsof  | grep /var/run/php | awk '{print  $9}' | sort -u | cut -d'/' -f5 | awk -F'-' '{print $1,$3}' | cut -d'.' -f1,2
1 Like

Indeed, that was a misreading on my part.

Thanks for your advices!

$ sudo lsof  | grep /var/run/php | awk '{print  $9}' | sort -u | cut -d'/' -f5 | awk -F'-' '{print $1,$3}' | cut -d'.' -f1,2                                                                       
[sudo] password for XXXXX:                                                                                                                                                                                      
php8.1 nextcloud                                                                                                                                                                                                  
php8.2 baikal                                                                                                                                                                                                     
php8.2 jirafeau                                                                                                                                                                                                   
php8.2 snappymail

Then I ran:

$ sudo apt remove php7.4-fpm php8.0-fpm
Reading package lists... Done                                                                                                                                                                                     
Building dependency tree... Done                                                                                                                                                                                  
Reading state information... Done                                                                                                                                                                                 
The following additional packages will be installed:                                                                                                                                                              
  php8.0-cgi                                                                                                                                                                                                      
The following packages will be REMOVED:                                                                                                                                                                           
  php7.4-fpm php8.0 php8.0-fpm                                                                                                                                                                                    
The following NEW packages will be installed:                                                                                                                                                                     
  php8.0-cgi                                                                                                                                                                                                      
0 upgraded, 1 newly installed, 3 to remove and 0 not upgraded.

Someone knows why “php8.0-cgi” was installed?

No, I don’t know.
If you really want to clean this 2 versions of php, you must use the wildcard because there are also other packages related to php.
You could try sudo apt remove php8.0* --purge and see if apt still wants to install php8.0-cgi.
If you want to see the list before:

dpkg -l | grep ^ii | grep  php8.0 | cut -d' ' -f3

or

apt list --installed | grep php8.0 | cut -d'/' -f1

Hello all,
Very interesting subject. I’ve checked my yunohost instance, and I saw that it was running 4 php version at the same time (7.3, 7.4, 8.0 and 8.1). the lsof command given above by @metyun told me that only php 8.1 was necessary (my yunohost instance only runs nextcloud)
So I’ve removed all the other prior php version, and no problem!
Thanks for the tip!

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.