Lamp apache architecture of communication configuration with php-fpm (tcp domain socket in communication with the communication unix)

Mode 1: The tcp: port mode

apache configuration:

#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 configuration:

listen = 127.0.0.1:9000

Second way; mode using 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 configuration:

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

======================
the Apache's proxy configuration file on fcgi agreement, the official document: https: //httpd.apache.org/docs/2.4/mod /mod_proxy_fcgi.html
glad to add micro-channel to discuss technical issues: 1415035017

Published 31 original articles · won praise 0 · Views 2810

Guess you like

Origin blog.csdn.net/yaqiang2017/article/details/104214926