第一种方法(SetHandler)
追加到/etc/httpd/conf/httpd.conf最后
<FilesMatch .php$> setHandler "proxy:fcgi://127.0.0.1:9000" </FilesMatch>
第二种方法(ProxyPassMatch)
虚拟主机内配置
<VirtualHost *:80> ServerName www.a.com DocumentRoot /var/www/html/ ProxyRequests Off ProxyPassMatch ^/(.*.php)$ fcgi://127.0.0.1:9000/var/www/html/$1 </VirtualHost>
第三种方法(ProxyPass)
虚拟主机内配置
<VirtualHost *:80>
ServerName www.a.com
DocumentRoot /var/www/html/
<LocationMatch ^(.*.php)$>
ProxyPass fcgi://127.0.0.1:9000/var/www/html/
ProxyErrorOverride on
</LocationMatch>
</VirtualHost>
测试PHP-FPM
Check if fastCGI enabled
<?php
// You can use isset or is_null for $_SERVER['FCGI_SERVER_VERSION']
function isFastCGI () {
return !is_null($_SERVER['FCGI_SERVER_VERSION']);
}
?>
FastCGI 进程管理器(FPM):https://www.php.net/manual/zh/install.fpm.php
Unix系统下的Apache2.X:https://www.php.net/manual/zh/install.unix.apache2.php