FCGI: attempt to connect to 127.0.0.1:9000 (*) failed Apache 2.4, PHP7.1-FPM with unix socket
It was, in the end, a simple mistake.
I was editing a www.conf
file at /etc/php-fpm.d/www.conf
which turns out to be there from the default MacOS installation.
The www.conf
file for PHP7.1-FPM that I installed with Brew was at:
/usr/local/etc/php/7.1/php-fpm.d/www.conf
.
Once I changed the listen
directive at /usr/local/etc/php/7.1/php-fpm.d/www.conf
I was off to the races.
Finn LeSueur
Updated on September 18, 2022Comments
-
Finn LeSueur over 1 year
I am trying to set up PHP7.1-FPM on MacOS Mojave! I followed this guide and got all the way through to the end when it stopped working.
During searching Google I decided to try and use unix sockets instead, so some of my configuration differs slightly to the guide I tried to follow.
I've got my services installed:
$ sudo brew services list Name Status User Plist httpd started root /Library/LaunchDaemons/homebrew.mxcl.httpd.plist [email protected] started root /Library/LaunchDaemons/[email protected]
I've set up my
httpd.conf
:# # DirectoryIndex: sets the file that Apache will serve if a directory # is requested. # <IfModule dir_module> DirectoryIndex index.php index.html index.htm </IfModule> <VirtualHost *:*> ProxyPassMatch "^/(.*\.php(/.*)?)$" "fcgi://127.0.0.1:9000/usr/local/var/www/$1" </VirtualHost> <FilesMatch \.php$> SetHandler "proxy:unix:/usr/var/run/php7.1-fpm.sock|fcgi://localhost/" </FilesMatch>
In my
/etc/php-fpm.d/www.conf
I've gotlisten = /var/run/php/php7.1-fpm.sock
If I check for the processes it seems all good:
$ ps aux | grep php-fpm 10.2s Thu 17 Jan 14:15:40 2019 finnlesueur 3718 0.0 0.0 4268052 692 s001 S+ 12:28pm 0:00.01 tail -f /usr/local/var/log/php-fpm.log finnlesueur 30588 0.0 0.0 4268060 812 s000 S+ 2:15pm 0:00.00 grep --color=auto php-fpm _www 29371 0.0 0.0 4520960 1180 ?? S 2:08pm 0:00.00 /usr/local/opt/[email protected]/sbin/php-fpm --nodaemonize _www 29370 0.0 0.0 4520960 1080 ?? S 2:08pm 0:00.00 /usr/local/opt/[email protected]/sbin/php-fpm --nodaemonize root 29366 0.0 0.1 4518912 30808 ?? Ss 2:08pm 0:00.08 /usr/local/opt/[email protected]/sbin/php-fpm --nodaemonize $ ps aux | grep httpd finnlesueur 29346 0.0 0.0 4345112 1832 ?? S 2:08pm 0:00.00 /usr/local/opt/httpd/bin/httpd -D FOREGROUND root 29332 0.0 0.0 4309296 2720 ?? Ss 2:08pm 0:00.09 /usr/local/opt/httpd/bin/httpd -D FOREGROUND finnlesueur 30727 0.0 0.0 4268060 812 s000 S+ 2:16pm 0:00.00 grep --color=auto httpd finnlesueur 29350 0.0 0.0 4328728 1172 ?? S 2:08pm 0:00.00 /usr/local/opt/httpd/bin/httpd -D FOREGROUND finnlesueur 29349 0.0 0.0 4345112 1180 ?? S 2:08pm 0:00.00 /usr/local/opt/httpd/bin/httpd -D FOREGROUND finnlesueur 29348 0.0 0.0 4353304 1184 ?? S 2:08pm 0:00.00 /usr/local/opt/httpd/bin/httpd -D FOREGROUND finnlesueur 29347 0.0 0.0 4335896 1192 ?? S 2:08pm 0:00.00 /usr/local/opt/httpd/bin/httpd -D FOREGROUND
My
DocumentRoot
has anindex.php
where it's just echoingphpinfo();
and that also seems fine, but when I load localhost I see503 Service Unavailable
and in my HTTP error log I get:[Thu Jan 17 14:18:57.654807 2019] [authz_core:debug] [pid 29347] mod_authz_core.c(817): [client ::1:57866] AH01626: authorization result of Require all granted: granted [Thu Jan 17 14:18:57.654991 2019] [authz_core:debug] [pid 29347] mod_authz_core.c(817): [client ::1:57866] AH01626: authorization result of <RequireAny>: granted [Thu Jan 17 14:18:57.655083 2019] [authz_core:debug] [pid 29347] mod_authz_core.c(845): [client ::1:57866] AH01628: authorization result: granted (no directives) [Thu Jan 17 14:18:57.655119 2019] [proxy_fcgi:debug] [pid 29347] mod_proxy_fcgi.c(108): [client ::1:57866] AH01060: set r->filename to proxy:fcgi://127.0.0.1:9000/usr/local/var/www/index.php [Thu Jan 17 14:18:57.655162 2019] [proxy:debug] [pid 29347] mod_proxy.c(1246): [client ::1:57866] AH01143: Running scheme fcgi handler (attempt 0) [Thu Jan 17 14:18:57.655171 2019] [proxy_fcgi:debug] [pid 29347] mod_proxy_fcgi.c(1019): [client ::1:57866] AH01076: url: fcgi://127.0.0.1:9000/usr/local/var/www/index.php proxyname: (null) proxyport: 0 [Thu Jan 17 14:18:57.655183 2019] [proxy_fcgi:debug] [pid 29347] mod_proxy_fcgi.c(1028): [client ::1:57866] AH01078: serving URL fcgi://127.0.0.1:9000/usr/local/var/www/index.php [Thu Jan 17 14:18:57.655191 2019] [proxy:debug] [pid 29347] proxy_util.c(2313): AH00942: FCGI: has acquired connection for (*) [Thu Jan 17 14:18:57.655199 2019] [proxy:debug] [pid 29347] proxy_util.c(2367): [client ::1:57866] AH00944: connecting fcgi://127.0.0.1:9000/usr/local/var/www/index.php to 127.0.0.1:9000 [Thu Jan 17 14:18:57.655219 2019] [proxy:debug] [pid 29347] proxy_util.c(2576): [client ::1:57866] AH00947: connected /usr/local/var/www/index.php to 127.0.0.1:9000 [Thu Jan 17 14:18:57.655346 2019] [proxy:error] [pid 29347] (61)Connection refused: AH00957: FCGI: attempt to connect to 127.0.0.1:9000 (*) failed [Thu Jan 17 14:18:57.655367 2019] [proxy_fcgi:error] [pid 29347] [client ::1:57866] AH01079: failed to make connection to backend: 127.0.0.1 [Thu Jan 17 14:18:57.655375 2019] [proxy:debug] [pid 29347] proxy_util.c(2328): AH00943: FCGI: has released connection for (*)
And nothing makes it to my PHP-FPM log, I guess because the connection has not been made.
I've been Googling for hours but can't seem to find anything that works. Any help would be appreciated!
Let me know if there's extra information I can provide!
Update 1
$ sudo lsof -U | grep php php-fpm 29366 root 5u unix 0xf497a489280ca0c1 0t0 ->0xf497a489280c91e9 php-fpm 29366 root 6u unix 0xf497a489280c91e9 0t0 ->0xf497a489280ca0c1 php-fpm 29366 root 7u unix 0xf497a489280c9a81 0t0 /var/run/php/php7.1-fpm.sock php-fpm 29370 _www 8u unix 0xf497a489280c9a81 0t0 /var/run/php/php7.1-fpm.sock php-fpm 29371 _www 8u unix 0xf497a489280c9a81 0t0 /var/run/php/php7.1-fpm.sock