docker apache php-fpm AH01071: Got error ‘Primary script unknown\n’

Here’s the background:
In Docker, a container Alpine runs Apache (2.4.33, MPm_Event),
The other container runs PHP-FPM (7.2.8), so Apache and PHP-FPM are in remote linkage mode.

Many Settings refer to a large number of night data debugging, and all errors are reported:
AH01071: Got error ‘Primary script unknown\n’

After verification of configuration one by one, it is inconceivable that the problem is found. Let’s first give the correct configuration:
1. HTTPD. Conf
* Clear out lines like AddType Application/x-httpd-PHP PHP php7, which are not used by PHP-FPM.
* Similar paragraphs like the following are not required in httpd.conf:
< FilesMatch \.php$> SetHandler “proxy:fcgi://php-fpm:9000” < /FilesMatch>

2. The correct configuration requires only one line:
ProxyPassMatch ^/(.*\.php(/.*)?) $ fcgi://php-fpm:9000/v/php-fpm/www/$1
Put this line in your vhost.conf < VirtualHost> In the water.

Pay special attention!
1. My DocumentRoot path and the last path of ProxyPassMatch do not match!
(DocumentRoot/V/Apache/WWW) Apache startup needs to actually detect the existence of DocumentRoot path memory. That is, my data is in the Apache container, and after fCGI :// pushes the data to the PHP-FPM container, the PHP-FPM container needs to read this/V/Apache/WWW path, if it does not read, it will report an error AH01071. The foreground page says “File Not Find!”

Therefore, the core idea of the solution is to make the two containers have a common accessible file address. This is not redundant, with mount and other ways to solve.

2. Note the phP-FPM listen Settings
\php-fpm.d\www.conf
My listen = 172.0.0.3:9000
Here you cannot write 127.0.0.1, two containers in a virtual Intranet segment, and you can also write the Intranet address of the segment.

Read More: