Ubuntu:Apache2 未加载 PHP-FPM php.ini

Ubuntu:Apache2 未加载 PHP-FPM php.ini

我需要一些关于 Apache2 无法加载 php-fpm php.ini 的帮助。我已成功安装 php-fpm,创建了池和其他配置,但 Apache2 不会将服务器 API 从更改Apache 2.0 HandlerFPM/FastCGI

Apache2 中的 fastcgi.conf

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>

然后在我的 vhost 条目中添加一行:

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

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信息:

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 

我期望的是:

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 

我错过了什么?

答案1

确保您没有libapache2-mod-php安装。Apache 报告说它正在使用此模块而不是 php-fpm。

sudo apt purge libapache2-mod-php

然后重新启动 httpd。

sudo systemctl restart apache2

相关内容