配置httpd 支持 fastcgi
注意:在HTTPD服务器上必须启用proxy_fcgi_module模块,才能充当php-fpm客户端
[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 to suppress 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.so
LoadModule lbmethod_byrequests_module modules/mod_lbmethod_byrequests.so
LoadModule lbmethod_bytraffic_module modules/mod_lbmethod_bytraffic.so
LoadModule lbmethod_heartbeat_module modules/mod_lbmethod_heartbeat.so
LoadModule proxy_ajp_module modules/mod_proxy_ajp.so
LoadModule proxy_balancer_module modules/mod_proxy_balancer.so
LoadModule proxy_connect_module modules/mod_proxy_connect.so
LoadModule proxy_express_module modules/mod_proxy_express.so
LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so
LoadModule proxy_fdpass_module modules/mod_proxy_fdpass.so
LoadModule proxy_ftp_module modules/mod_proxy_ftp.so
LoadModule proxy_http_module modules/mod_proxy_http.so
LoadModule proxy_hcheck_module modules/mod_proxy_hcheck.so
LoadModule proxy_scgi_module modules/mod_proxy_scgi.so
LoadModule 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
ProxyRequests Off
ProxyPassMatch ^/(.*/.php)fcgi://php-fpm服务器IP:9000/var/www/html/1
#以上开启FCGI反向代理,“^/”这处的”/“相对于后面的/var/www/html而言,后面的$1是指前面的/(.*.php)
说明:
如果php-fpm和httpd在同一台主机,也可以用 UDS(unix domain socket)方式
ProxyPassMatch ^/(.*/.php)unix:/var/run/php.sock|fcgi://localhost/app/httpd24/htdocs/1
参看:http://httpd.apache.org/docs/2.4/mod/mod_proxy_fcgi.html
实战案例:虚拟主机配置支持FCGI
vim /etc/httpd/conf.d/vhosts.conf
DirectoryIndex index.php
<VirtualHost *:80>
ServerName www.magedu.net
DocumentRoot /apps/vhosts/magedu.net
ProxyRequests Off
ProxyPassMatch ^/(.*/.php)fcgi://127.0.0.1:9000/apps/vhosts/magedu.net/1
<Directory "/apps/vhosts/magedu.net">
Options None
AllowOverride None
Require all granted
</Directory>
</VirtualHost>
本文链接:http://www.yunweipai.com/36099.html
原创文章,作者:Maggie-Hunter,如若转载,请注明出处:https://blog.ytso.com/52445.html