valet: PHP 7.2 won't start. Warning: The post-install step did not complete successfully (PHP@7.2, Catalina)

After following the instructions on https://github.com/laravel/valet/issues/326 and various other locations, I’m still not able to get valet to serve a page after a successful install. I’m running off php@7.2 as php@7.3 errors, and several of the codebases I’m running aren’t quite yet ready for 7.4.

Commands run:

valet stop
valet uninstall
rm -rf ~/.valet
composer global remove laravel/valet

brew unlink nginx && brew remove nginx && brew uninstall --ignore-dependencies nginx
brew unlink php@7.2 && brew remove php@7.2 && brew uninstall --ignore-dependencies php@7.2
brew unlink dnsmasq && brew remove dnsmasq && brew uninstall --ignore-dependencies dnsmasq

brew update
brew upgrade
brew cleanup
brew doctor

brew install nginx
brew install php@7.2
brew install dnsmasq

sudo brew services start --all

brew link --force php@7.2
composer global require laravel/valet
valet install

The brew link was needed as the composer global require fails with:

[ErrorException]
"continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"?

otherwise.

When trying to visit a configured site I’m seeing this in ~/.config/valet/Log/nginx-error.log:

2019/12/05 12:14:49 [crit] 27422#0: *1 connect() to unix:/Users/brianhogg/.config/valet/valet.sock failed (2: No such file or directory) while connecting to upstream, client: 127.0.0.1, server: , request: "GET /favicon.ico HTTP/1.1", upstream: "fastcgi://unix:/Users/brianhogg/.config/valet/valet.sock:", host: "mysite.test", referrer: "http://mysite.test/"

Thinking it might be related to php-fpm (which should be installed automatically with brew install php@7.2 and valet install?) I’m seeing this:

php-fpm
[05-Dec-2019 12:20:27] ERROR: failed to open configuration file '/private/etc/php-fpm.conf': No such file or directory (2)
[05-Dec-2019 12:20:27] ERROR: failed to load configuration file '/private/etc/php-fpm.conf'
[05-Dec-2019 12:20:27] ERROR: FPM initialization failed

At this point I’m stuck. Any help appreciated 😃

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 24 (7 by maintainers)

Most upvoted comments

I’ve now fixed the issue.

I found it that when I ran brew install php it gave the following warning:

==> Pouring php-7.4.8.high_sierra.bottle.tar.gz
Warning: The post-install step did not complete successfully
You can try again using `brew postinstall php`

I then ran brew postinstall php --debug which gave me

Warning: The post-install step did not complete successfully
You can try again using `brew postinstall php`
==> An exception occurred within a child process:
  Errno::EACCES: Permission denied @ rb_sysopen - /usr/local/etc/php/7.4/pear.conf

So, I did 777 on the /usr/local/etc/php/7.4/

sudo chmod 777 /usr/local/etc/php/7.4/

Then re-ran, and everything worked like a charm.

@drbyte no problem! updated the title to reflect the latest thread and root cause.

Great! I’m glad the root cause has been found and resolved.

It may be beneficial to update (again) the title of this issue to be more about the old 7.2 leftover fragments issue than about the 502 gateway issue, since the 502 thing is a very generic symptom vs the root cause. While this is really long, maybe something akin to: “PHP 7.2 won’t start. Warning: The post-install step did not complete successfully” ?

Success! Rebooted after ensuring the /usr/local/etc/php configs were fully removed, ran valet use php@7.2 and looks like I’ve got valet running with php 7.2 successfully.

Thanks again for all the help. Not sure if there’s something in the above that can be actioned on to provide additional messaging, but will close this issue as it seems to be all good on a clean install.

Thanks! I didn’t realize --debug was an option. That gave the clue:

brew postinstall php@7.2 --debug
/usr/local/Homebrew/Library/Homebrew/brew.rb (Formulary::FormulaLoader): loading /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/php@7.2.rb
==> Postinstalling php@7.2
Warning: The post-install step did not complete successfully
You can try again using `brew postinstall php@7.2`
==> An exception occurred within a child process:
  Errno::EACCES: Permission denied @ rb_sysopen - /usr/local/etc/php/7.2/pear.conf

I thought I had already removed all the /usr/local/etc/php configs before the reboot but must not have. chown’ed the permissions, re-ran postinstall, and finished with no errors. However even though valet use php@7.2 now completes without error, I still get the same valet.sock error in the nginx logs.

I’ve uninstalled php@7.2 with brew uninstall php@7.2 and will try blowing away all the non-7.4 configs, rebooting, and re-trying valet use php@7.2. Fingers crossed 😃