valet: `valet install` results in PHP service restarting with error

➜  ~ brew services list
Name      Status  User Plist
dnsmasq   started root /Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist
mysql@5.7 started ryan /Users/ryan/Library/LaunchAgents/homebrew.mxcl.mysql@5.7.plist
nginx     started root /Library/LaunchDaemons/homebrew.mxcl.nginx.plist
php       error   root /Library/LaunchDaemons/homebrew.mxcl.php.plist
redis     started ryan /Users/ryan/Library/LaunchAgents/homebrew.mxcl.redis.plist

Not sure why but every time I run valet install my php service is in an error status. Manually running brew services restart php brings it up without error with a status of started.

Am I doing something wrong or is there a log file I can check or something?

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 21 (6 by maintainers)

Most upvoted comments

I fixed my issue last night by doing this:

  1. brew uninstall php
  2. brew uninstall php@5.6
  3. brew uninstall php@7.1
  4. brew uninstall php@7.2
  5. brew cleanup
  6. brew services cleanup
  7. sudo brew services cleanup
  8. brew doctor
  9. brew update
  10. brew install php
  11. valet install

My /usr/local/var/log/php-fpm.log doesn’t get spammed with that junk anymore.

I haven’t tried reinstalling the older versions of php though as I’m afraid the issue might come back. I’m currently running php 7.3.1

edit: I suspect the issue has something to do with having multiple versions of PHP installed with homebrew. Though simply having the services stopped didn’t seem to matter, they needed to actually be uninstalled.

I am extremely sorry. The issue I have been fighting with all day was the fact i was getting spammed in my php-fpm.log. I was getting spammed with

[08-Jan-2020 17:02:31] ERROR: Another FPM instance seems to already listen on /Users/joe/.config/valet/valet.sock [08-Jan-2020 17:02:31] ERROR: Another FPM instance seems to already listen on /Users/joe/.config/valet/valet.sock [08-Jan-2020 17:02:31] ERROR: FPM initialization failed [08-Jan-2020 17:02:31] ERROR: FPM initialization failed [08-Jan-2020 17:02:31] NOTICE: [pool valet] 'user' directive is ignored when FPM is not running as root [08-Jan-2020 17:02:31] NOTICE: [pool valet] 'user' directive is ignored when FPM is not running as root [08-Jan-2020 17:02:31] NOTICE: [pool valet] 'group' directive is ignored when FPM is not running as root [08-Jan-2020 17:02:31] NOTICE: [pool valet] 'group' directive is ignored when FPM is not running as root [08-Jan-2020 17:02:31] ERROR: Another FPM instance seems to already listen on /Users/joe/.config/valet/valet.sock [08-Jan-2020 17:02:31] ERROR: Another FPM instance seems to already listen on /Users/joe/.config/valet/valet.sock [08-Jan-2020 17:02:31] ERROR: FPM initialization failed [08-Jan-2020 17:02:31] ERROR: FPM initialization failed [08-Jan-2020 17:02:41] ERROR: Another FPM instance seems to already listen on /Users/joe/.config/valet/valet.sock [08-Jan-2020 17:02:41] ERROR: Another FPM instance seems to already listen on /Users/joe/.config/valet/valet.sock [08-Jan-2020 17:02:41] ERROR: FPM initialization failed [08-Jan-2020 17:02:41] ERROR: FPM initialization failed [08-Jan-2020 17:02:41] NOTICE: [pool valet] 'user' directive is ignored when FPM is not running as root [08-Jan-2020 17:02:41] NOTICE: [pool valet] 'user' directive is ignored when FPM is not running as root [08-Jan-2020 17:02:41] NOTICE: [pool valet] 'group' directive is ignored when FPM is not running as root [08-Jan-2020 17:02:41] NOTICE: [pool valet] 'group' directive is ignored when FPM is not running as root [08-Jan-2020 17:02:41] ERROR: Another FPM instance seems to already listen on /Users/joe/.config/valet/valet.sock [08-Jan-2020 17:02:41] ERROR: Another FPM instance seems to already listen on /Users/joe/.config/valet/valet.sock [08-Jan-2020 17:02:41] ERROR: FPM initialization failed [08-Jan-2020 17:02:41] ERROR: FPM initialization failed

But I couldn’t understand why these kept popping up even after i uninstalled all versions of php and ran all the code @ryanmortier posted.

I dug a little deeper and noticed I had erroneous launch agents which were never removed by brew in

~/Library/LaunchAgents/ /Library/LaunchAgents

I uninstalled all versions of PHP from brew and then deleted out all the launchagents that still existed. I then reinstalled default php via brew and did a valet install. It seems to be behaving properly.

brew services restart php

Odd, I did

brew services stop php
brew services list

I noticed that after stopping it, it now said that php was started, when before it said there was an error. When I tried to stop it again it says:

Error: Service php is started as root. Try: sudo brew services stop php"

It seems to be running fine under root, but it seems that there was also a user service competing against the root service :\ so odd…

Now my log file is not growing constantly 😃 (hopefully this holds up for a reboot or valet restart.

Now I no longer see the php mxcl plist file in the ~/Library/LaunchAgents either.

brew services restart php

After that vulnerability in PHP-FPM a few days ago I had updated my php on a Catalina install and my fpm-php log blew up overnite with the exact errors above and crashed the computer (over 48GB log file, ran out of space). @ryanmortier - followed his steps, and now its working just fine!

I was getting the 502 errors in the browser and FPM initialization failed and An another FPM instance seems to already listen on... errors in my php-fpm.log file. It turned out that large cookies/headers were causing the issue. I created a .conf file in my ~/.config/valet/Nginx/ and added the following lines and it fixed it for me.

fastcgi_buffers 16 16k;
fastcgi_buffer_size 32k;
fastcgi_read_timeout 180;