配置httpd 支持 fastcgi
注意:在HTTPD服务器上必须启用proxy_fcgi_module模块,才能充当php-fpm客户端
[root@centos8 ~]#dnf -y install 1234567891011121314151617181920242223
[root@centos8 ~]#dnf -y install httpd php-fpm
[root@centos8 ~]#httpd -M |grep fcgi
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using centos8.localdomain. Set the 'ServerName' directive globally tosuppress this message
proxy_fcgi_module (shared)
[root@centos8 ~]#cat /etc/httpd/conf.modules.d/00-proxy.conf# This file configures all the proxy modules:
LoadModule proxy_module modules/mod_proxy.so
LoadModule lbmethod_bybusyness_module modules/mod_lbmethod_bybusyness.soLoadModule lbmethod_byrequests_module modules/mod_lbmethod_byrequests.soLoadModule lbmethod_bytraffic_module modules/mod_lbmethod_bytraffic.soLoadModule lbmethod_heartbeat_module modules/mod_lbmethod_heartbeat.soLoadModule proxy_ajp_module modules/mod_proxy_ajp.so
LoadModule proxy_balancer_module modules/mod_proxy_balancer.soLoadModule proxy_connect_module modules/mod_proxy_connect.soLoadModule proxy_express_module modules/mod_proxy_express.soLoadModule proxy_fcgi_module modules/mod_proxy_fcgi.soLoadModule proxy_fdpass_module modules/mod_proxy_fdpass.soLoadModule proxy_ftp_module modules/mod_proxy_ftp.soLoadModule proxy_http_module modules/mod_proxy_http.so
LoadModule proxy_hcheck_module modules/mod_proxy_hcheck.soLoadModule proxy_scgi_module modules/mod_proxy_scgi.soLoadModule proxy_uwsgi_module modules/mod_proxy_uwsgi.so
LoadModule proxy_wstunnel_module modules/mod_proxy_wstunnel.so
创建httpd的配置文件 /etc/httpd/conf.d/fcgi.conf ,内容如下
DirectoryIndex index.php 1DirectoryIndex index.php2ProxyRequests Off
3ProxyPassMatch ^/(.*\\.php)$ fcgi://php-fpm服务器IP:9000/var/www/html/$1
4#以上开启FCGI反向代理,“^/”这处的”/“相对于后面的/var/www/html而言,后面的$1是指前面的/(.*.php)
说明:
如果php-fpm和httpd在同一台主机,也可以用 UDS(unix domain socket)方式
ProxyPassMatch ^/(.*\\.php)$ 1ProxyPassMatch ^/(.*\\.php)$ unix:/var/run/php.sock|fcgi://localhost/app/httpd24/htdocs/$1
参看:http://httpd.apache.org/docs/2.4/mod/mod_proxy_fcgi.html
实战案例:虚拟主机配置支持FCGIvim /etc/httpd/conf.d/v1vim /etc/httpd/conf.d/vhosts.conf2DirectoryIndex index.php3