Lamp架构之apache与php-fpm通信配置(tcp通信与unix domain socket通信)

方式一:采用tcp:port模式

apache配置:

#Tell the PHP interpreter to handle files with a .php extension.

#Proxy declaration

<Proxy "fcgi://127.0.0.1">
</Proxy>

<FilesMatch "\.php$">
    SetHandler  "proxy:fcgi://127.0.0.1:9000"
</FilesMatch>

#
#Allow php to handle Multiviews
#
AddType text/html .php

#
#Add index.php to the list of files that will be served as directory
#indexes.
#
DirectoryIndex index.php

#
#Uncomment the following lines to allow PHP to pretty-print .phps
#files as PHP source code:
#echo php_sapi_name();//fpm-fcgi 
<FilesMatch \.phps$>
 SetHandler application/x-httpd-php-source
</FilesMatch>

php-fpm 配置:

listen = 127.0.0.1:9000

方式二;采用unix domain socket模式

#Tell the PHP interpreter to handle files with a .php extension.

#Proxy declaration
<Proxy "unix:/var/run/php-fpm/default.sock|fcgi://php-fpm">
 #we must declare a parameter in here (doesn't matter which) or it'll not register the proxy ahead of time
    ProxySet disablereuse=off
</Proxy>

#Redirect to the proxy
<FilesMatch \.php$>
 SetHandler proxy:fcgi://php-fpm
</FilesMatch>

#
#Allow php to handle Multiviews
#
AddType text/html .php

#
#Add index.php to the list of files that will be served as directory
#indexes.
#
DirectoryIndex index.php

#
#Uncomment the following lines to allow PHP to pretty-print .phps
#files as PHP source code:
#echo php_sapi_name();//fpm-fcgi 
<FilesMatch \.phps$>
 SetHandler application/x-httpd-php-source
</FilesMatch>

php-fpm 配置:

listen = /var/run/php-fpm/default.sock

======================
apache的proxy关于fcgi协议相关配置文档,官方文档:https://httpd.apache.org/docs/2.4/mod/mod_proxy_fcgi.html
很高兴加微信讨论相关技术问题:1415035017

发布了31 篇原创文章 · 获赞 0 · 访问量 2810

猜你喜欢

转载自blog.csdn.net/yaqiang2017/article/details/104214926