实战案例:httpd配置支持fastcgi

实战案例:httpd配置支持fastcgi,第1张

实战案例:httpd配置支持fastcgi 配置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而言,后面的是指前面的/(.*.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

    ServerName www.magedu.net
    documentRoot /apps/vhosts/magedu.net
    ProxyRequests Off
    ProxyPassMatch ^/(.*.php)fcgi://127.0.0.1:9000/apps/vhosts/magedu.net/1
    
        Options None
        AllowOverride None
        Require all granted
    
    

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/3012871.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-09-28
下一篇 2022-09-28

发表评论

登录后才能评论

评论列表(0条)

保存