Ubuntu: Apache2 not loading PHP-FPM php.ini

camilox asked:

I need some help on Apache2 not loading the php-fpm php.ini. I have installed php-fpm successfully, created the pool and other configurations but Apache2 doesn’t change the Server API from Apache 2.0 Handler to FPM/FastCGI

fastcgi.conf in Apache2

Action php-fcgi-tccuat-72 /php-fcgi-john-72
Alias /php-fcgi-tccuat-72 /usr/lib/cgi-bin/php-fcgi-john-72
FastCgiExternalServer /usr/lib/cgi-bin/php-fcgi-john-72 -socket /run/php-fpm-www-john-72.sock -idle-timeout 360 -pass-header Authorization
...
<Directory /usr/lib/cgi-bin>
        Options ExecCGI FollowSymLinks
        SetHandler fastcgi-script
        Require all granted
</Directory>

then added a line to my vhost entry:

...
 AddHandler php-fcgi-john-72 .php
...

Status of PHP-FPM

systemctl status php7.2-fpm
● php7.2-fpm.service - The PHP 7.2 FastCGI Process Manager
   Loaded: loaded (/lib/systemd/system/php7.2-fpm.service; enabled; vendor preset: enabled)
   Active: active (running) since Tue 2020-07-07 08:05:22 NZST; 16min ago
     Docs: man:php-fpm7.2(8)
  Process: 923 ExecStartPost=/usr/lib/php/php-fpm-socket-helper install /run/php/php-fpm.sock /etc/php/7.2/fpm/pool.d/www.co
 Main PID: 854 (php-fpm7.2)
   Status: "Processes active: 0, idle: 5, Requests: 0, slow: 0, Traffic: 0req/sec"
   CGroup: /system.slice/php7.2-fpm.service
           ├─854 php-fpm: master process (/etc/php/7.2/fpm/php-fpm.conf)                      
           ├─911 php-fpm: pool www-default-72                                                 
           ├─912 php-fpm: pool www-john-pub-72                                              
           ├─913 php-fpm: pool www-john-72                                                  
           ├─918 php-fpm: pool www                                                            
           └─922 php-fpm: pool www      

PHP Info:

PHP Version 7.2.31-1+ubuntu16.04.1+deb.sury.org+1


----------


System: Linux ansible3rd 4.15.0-45-generic #48~16.04.1-Ubuntu SMP Tue Jan 29 18:03:48 UTC 2019 x86_64
Build Date: May 14 2020 08:27:14
Server API: Apache 2.0 Handler
Virtual Directory Support: disabled
Configuration File (php.ini) Path: /etc/php/7.2/apache2
Loaded Configuration File: /etc/php/7.2/apache2/php.ini
Scan this dir for additional .ini files: /etc/php/7.2/apache2/conf.d 

What I am expecting is:

Server API: FPM/FastCGI
Virtual Directory Support: disabled
Configuration File (php.ini) Path: /etc/php/7.2/fpm
Loaded Configuration File: /etc/php/7.2/fpm/php.ini
Scan this dir for additional .ini files: /etc/php/7.2/fpm/conf.d 

Did I miss something?

My answer:


Make sure you don’t have libapache2-mod-php installed. Apache is reporting that it is using this module instead of php-fpm.

sudo apt purge libapache2-mod-php

Then restart httpd.

sudo systemctl restart apache2

View the full question and any other answers on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.