Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHP 7.2 won't start. Warning: The post-install step did not complete successfully ([email protected], Catalina) #865

Closed
brianhogg opened this issue Dec 5, 2019 · 24 comments

Comments

@brianhogg
Copy link

brianhogg commented Dec 5, 2019

After following the instructions on #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 [email protected] as [email protected] 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 [email protected] && brew remove [email protected] && brew uninstall --ignore-dependencies [email protected]
brew unlink dnsmasq && brew remove dnsmasq && brew uninstall --ignore-dependencies dnsmasq

brew update
brew upgrade
brew cleanup
brew doctor

brew install nginx
brew install [email protected]
brew install dnsmasq

sudo brew services start --all

brew link --force [email protected]
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 [email protected] 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 :)

@drbyte
Copy link
Contributor

drbyte commented Dec 5, 2019

Observations:

  • rm -rf ~/.valet is for older Valet versions. A year or so ago it was changed to ~/.config/valet
  • Your reinstall process shows you installing php71 but then forcing brew link on [email protected].
  • the "continue" targeting switch is equivalent to "break". sounds like a PHP error from a mismatch of PHP versions, which suggests that your global composer may have some incompatible packages vs whatever PHP version is firing. Have you run composer global update after installing the desired PHP version? before the global require of valet? What else is in your global composer json (ie: do you really need everything you've got listed in there?)
  • the valet.sock file won't be created if the valet PHP config isn't set properly and if PHP isn't running
  • failed to load configuration file '/private/etc/php-fpm.conf' is pointing to /private/etc which appears to be your Mac's default PHP config, and not homebrew.

I think you're not really running Homebrew's PHP, but rather your mac's default PHP.

And I wonder if your PATH is properly loading homebrew's binaries before the defaults your Mac comes with.

Also, some of the following diags may reveal useful information (EDIT: which are now built-in to valet diagnose):

sw_vers
valet --version
cat ~/.config/valet/config.json
ls -al /etc/sudoers.d/
openssl version -a
openssl ciphers
php -v
which php
which -a php
nginx -v
curl --version
php --ri curl
brew config
brew doctor
brew info openssl
brew info nginx
brew info php
~/.composer/vendor/laravel/valet/bin/ngrok version
ls -al ~/.ngrok2
sudo nginx -t

@brianhogg
Copy link
Author

@drbyte Thanks for the reply! Apologies I missed updating the commands to what I actually ran after copy/pasting them from that linked issue. I was running [email protected] on all the steps.

Here's the full history of trying it again. I tried a couple different ways to get the brew postinstall step to work but no luck:

✝  ~  valet uninstall
Password:
Stopping nginx...
Valet has been uninstalled.
 ✝  ~  rm -rf ~/.config/valet
 ✝  ~  composer global remove laravel/valet
Changed current directory to /Users/brianhogg/.composer
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 0 installs, 0 updates, 9 removals
  - Removing laravel/valet (v2.5.4)
  - Removing illuminate/container (v6.6.2)
  - Removing illuminate/contracts (v6.6.2)
  - Removing psr/simple-cache (1.0.1)
  - Removing mnapoli/silly (1.7.2)
  - Removing php-di/invoker (2.0.0)
  - Removing nategood/httpful (0.2.20)
  - Removing tightenco/collect (v6.5.2)
  - Removing symfony/var-dumper (v5.0.1)
Writing lock file
Generating autoload files
 ✝  ~  brew unlink nginx && brew remove nginx && brew uninstall --ignore-dependencies nginx
Unlinking /usr/local/Cellar/nginx/1.17.3_1... 3 symlinks removed
Uninstalling /usr/local/Cellar/nginx/1.17.3_1... (25 files, 2MB)
Error: Could not remove nginx keg! Do so manually:
  sudo rm -rf /usr/local/Cellar/nginx/1.17.3_1
 ✘ ✝  ~  sudo rm -rf /usr/local/Cellar/nginx/1.17.3_1
Password:
 ✝  ~  brew unlink [email protected] && brew remove [email protected] && brew uninstall --ignore-dependencies [email protected]
Unlinking /usr/local/Cellar/[email protected]/7.2.25... 25 symlinks removed
Uninstalling /usr/local/Cellar/[email protected]/7.2.25... (514 files, 74.8MB)
Error: Could not remove [email protected] keg! Do so manually:
  sudo rm -rf /usr/local/Cellar/[email protected]/7.2.25
 ✘ ✝  ~  sudo rm -rf /usr/local/Cellar/[email protected]/7.2.25
 ✝  ~  brew unlink dnsmasq && brew remove dnsmasq && brew uninstall --ignore-dependencies dnsmasq

Unlinking /usr/local/Cellar/dnsmasq/2.80... 2 symlinks removed
Uninstalling /usr/local/Cellar/dnsmasq/2.80... (8 files, 531.3KB)
Error: Could not remove dnsmasq keg! Do so manually:
  sudo rm -rf /usr/local/Cellar/dnsmasq/2.80
 ✘ ✝  ~  sudo rm -rf /usr/local/Cellar/dnsmasq/2.80
 ✝  ~  brew update
Updated 1 tap (homebrew/cask).
No changes to formulae.
 ✝  ~  brew upgrade
 ✝  ~  brew cleanup
Pruned 4 symbolic links and 4 directories from /usr/local
 ✝  ~  brew doctor
Your system is ready to brew.
 ✝  ~  brew install nginx
==> Downloading https://homebrew.bintray.com/bottles/nginx-1.17.3_1.catalina.bottle.tar.gz
Already downloaded: /Users/brianhogg/Library/Caches/Homebrew/downloads/73918b9a966ec5af47ad27b953512834ea07f45703516d6fa697a97ad829dc2c--nginx-1.17.3_1.catalina.bottle.tar.gz
==> Pouring nginx-1.17.3_1.catalina.bottle.tar.gz
==> Caveats
Docroot is: /usr/local/var/www

The default port has been set in /usr/local/etc/nginx/nginx.conf to 8080 so that
nginx can run without sudo.

nginx will load all files in /usr/local/etc/nginx/servers/.

To have launchd start nginx now and restart at login:
  brew services start nginx
Or, if you don't want/need a background service you can just run:
  nginx
==> Summary
🍺  /usr/local/Cellar/nginx/1.17.3_1: 25 files, 2MB
 ✝  ~  brew install [email protected]
==> Downloading https://homebrew.bintray.com/bottles/[email protected]
Already downloaded: /Users/brianhogg/Library/Caches/Homebrew/downloads/c881b11206f0cc92afb0516d7517e2af37a1e52511e45002b33ec2d5c1897c4c--php@7.2-7.2.25.catalina.bottle.tar.gz
==> Pouring [email protected]
Warning: The post-install step did not complete successfully
You can try again using `brew postinstall [email protected]`
==> Caveats
To enable PHP in Apache add the following to httpd.conf and restart Apache:
    LoadModule php7_module /usr/local/opt/[email protected]/lib/httpd/modules/libphp7.so

    <FilesMatch \.php$>
        SetHandler application/x-httpd-php
    </FilesMatch>

Finally, check DirectoryIndex includes index.php
    DirectoryIndex index.php index.html

The php.ini and php-fpm.ini file can be found in:
    /usr/local/etc/php/7.2/

[email protected] is keg-only, which means it was not symlinked into /usr/local,
because this is an alternate version of another formula.

If you need to have [email protected] first in your PATH run:
  echo 'export PATH="/usr/local/opt/[email protected]/bin:$PATH"' >> ~/.zshrc
  echo 'export PATH="/usr/local/opt/[email protected]/sbin:$PATH"' >> ~/.zshrc

For compilers to find [email protected] you may need to set:
  export LDFLAGS="-L/usr/local/opt/[email protected]/lib"
  export CPPFLAGS="-I/usr/local/opt/[email protected]/include"


To have launchd start [email protected] now and restart at login:
  brew services start [email protected]
Or, if you don't want/need a background service you can just run:
  php-fpm
==> Summary
🍺  /usr/local/Cellar/[email protected]/7.2.25: 514 files, 74.8MB
 ✘ ✝  ~  brew postinstall [email protected]
==> Postinstalling [email protected]
Warning: The post-install step did not complete successfully
You can try again using `brew postinstall [email protected]`
 ✘ ✝  ~  php -v
PHP 7.3.9 (cli) (built: Sep 10 2019 17:45:01) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.9, Copyright (c) 1998-2018 Zend Technologies
 ✝  ~  ls ~/Library/Logs/Homebrew/[email protected]
 ✝  ~  /usr/local/opt/[email protected]/bin/php -m
[PHP Modules]
bcmath
bz2
calendar
Core
ctype
curl
date
dba
dom
exif
fileinfo
filter
ftp
gd
gettext
gmp
hash
iconv
intl
json
ldap
libxml
mbstring
mysqli
mysqlnd
odbc
openssl
pcntl
pcre
PDO
pdo_dblib
pdo_mysql
PDO_ODBC
pdo_pgsql
pdo_sqlite
pgsql
Phar
phpdbg_webhelper
posix
pspell
readline
Reflection
session
shmop
SimpleXML
soap
sockets
sodium
SPL
sqlite3
standard
sysvmsg
sysvsem
sysvshm
tidy
tokenizer
wddx
xml
xmlreader
xmlrpc
xmlwriter
xsl
zip
zlib

[Zend Modules]

 ✝  ~  brew list php
Error: No such keg: /usr/local/Cellar/php
 ✘ ✝  ~  brew list [email protected]
/usr/local/Cellar/[email protected]/7.2.25/.bottle/etc/ (4 files)
/usr/local/Cellar/[email protected]/7.2.25/.bottle/var/log/php-fpm.log
/usr/local/Cellar/[email protected]/7.2.25/bin/pear
/usr/local/Cellar/[email protected]/7.2.25/bin/peardev
/usr/local/Cellar/[email protected]/7.2.25/bin/pecl
/usr/local/Cellar/[email protected]/7.2.25/bin/phar
/usr/local/Cellar/[email protected]/7.2.25/bin/phar.phar
/usr/local/Cellar/[email protected]/7.2.25/bin/php
/usr/local/Cellar/[email protected]/7.2.25/bin/php-cgi
/usr/local/Cellar/[email protected]/7.2.25/bin/php-config
/usr/local/Cellar/[email protected]/7.2.25/bin/phpdbg
/usr/local/Cellar/[email protected]/7.2.25/bin/phpize
/usr/local/Cellar/[email protected]/7.2.25/[email protected]
/usr/local/Cellar/[email protected]/7.2.25/include/php/ (310 files)
/usr/local/Cellar/[email protected]/7.2.25/lib/httpd/modules/libphp7.so
/usr/local/Cellar/[email protected]/7.2.25/lib/php/ (14 files)
/usr/local/Cellar/[email protected]/7.2.25/sbin/php-fpm
/usr/local/Cellar/[email protected]/7.2.25/share/man/ (8 files)
/usr/local/Cellar/[email protected]/7.2.25/share/php/fpm/status.html
/usr/local/Cellar/[email protected]/7.2.25/share/[email protected]/ (158 files)
 ✝  ~  sudo brew postinstall [email protected]
Password:
Error: Running Homebrew as root is extremely dangerous and no longer supported.
As Homebrew does not drop privileges on installation you would be giving all
build scripts full access to your system.
 ✘ ✝  ~  brew postinstall [email protected]
==> Postinstalling [email protected]
Warning: The post-install step did not complete successfully
You can try again using `brew postinstall [email protected]`
 ✘ ✝  ~  ls -la /usr/local/Cellar/[email protected]
total 0
drwxr-xr-x   3 brianhogg  staff    96  5 Dec 13:53 .
drwxrwxr-x  91 brianhogg  wheel  2912  5 Dec 12:09 ..
drwxr-xr-x  14 brianhogg  staff   448  5 Dec 13:53 7.2.25
 ✝  ~  ls -la /usr/local/Cellar/[email protected]/7.2.25
total 264
drwxr-xr-x  14 brianhogg  staff     448  5 Dec 13:53 .
drwxr-xr-x   3 brianhogg  staff      96  5 Dec 13:53 ..
drwxr-xr-x   4 brianhogg  staff     128 20 Nov 10:11 .bottle
drwxr-xr-x   3 brianhogg  staff      96 20 Nov 10:11 .brew
-rw-r--r--   1 brianhogg  staff    3175  5 Dec 13:53 INSTALL_RECEIPT.json
-rw-r--r--   1 brianhogg  staff    3204 20 Nov 10:11 LICENSE
-rw-r--r--   1 brianhogg  staff  116491 20 Nov 10:11 NEWS
-rw-r--r--   1 brianhogg  staff    1607 20 Nov 10:11 README.md
drwxr-xr-x  12 brianhogg  staff     384  5 Dec 13:53 bin
-rw-r--r--   1 brianhogg  staff     636  5 Dec 13:53 [email protected]
drwxr-xr-x   3 brianhogg  staff      96 20 Nov 10:11 include
drwxr-xr-x   4 brianhogg  staff     128 20 Nov 10:11 lib
drwxr-xr-x   3 brianhogg  staff      96 20 Nov 10:11 sbin
drwxr-xr-x   5 brianhogg  staff     160 20 Nov 10:11 share
 ✝  ~  sudo chown brianhogg:wheel /usr/local/etc/php/7.2/php-fpm.conf
Password:
 ✝  ~  brew postinstall [email protected]
==> Postinstalling [email protected]
Warning: The post-install step did not complete successfully
You can try again using `brew postinstall [email protected]`
 ✘ ✝  ~  brew install dnsmasq
Updating Homebrew...
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/cask).
No changes to formulae.

==> Downloading https://homebrew.bintray.com/bottles/dnsmasq-2.80.catalina.bottle.1.tar.gz
Already downloaded: /Users/brianhogg/Library/Caches/Homebrew/downloads/230d68b164836f0900a9880afe7a36e100b473f2f3eecbef353a1ad408211bc0--dnsmasq-2.80.catalina.bottle.1.tar.gz
==> Pouring dnsmasq-2.80.catalina.bottle.1.tar.gz
==> Caveats
To have launchd start dnsmasq now and restart at startup:
  sudo brew services start dnsmasq
==> Summary
🍺  /usr/local/Cellar/dnsmasq/2.80: 8 files, 531.3KB
 ✝  ~  sudo brew services start --all
Warning: Taking root:admin ownership of some nginx paths:
  /usr/local/Cellar/nginx/1.17.3_1/bin
  /usr/local/Cellar/nginx/1.17.3_1/bin/nginx
  /usr/local/opt/nginx
  /usr/local/opt/nginx/bin
  /usr/local/var/homebrew/linked/nginx
This will require manual removal of these paths using `sudo rm` on
brew upgrade/reinstall/uninstall.
==> Successfully started `nginx` (label: homebrew.mxcl.nginx)
Warning: Taking root:admin ownership of some [email protected] paths:
  /usr/local/Cellar/[email protected]/7.2.25/sbin
  /usr/local/Cellar/[email protected]/7.2.25/sbin/php-fpm
  /usr/local/opt/[email protected]
  /usr/local/opt/[email protected]/bin
  /usr/local/opt/[email protected]/sbin
This will require manual removal of these paths using `sudo rm` on
brew upgrade/reinstall/uninstall.
==> Successfully started `[email protected]` (label: [email protected])
 ✝  ~  echo $PATH
/usr/local/sbin:/Users/brianhogg/.composer/vendor/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
 ✝  ~  echo 'export PATH="/usr/local/Cellar/[email protected]/7.2.25/sbin:$PATH"' >> ~/.zshrc
 ✝  ~  source ~/.zshrc
 ✝  ~  php --version
PHP 7.3.9 (cli) (built: Sep 10 2019 17:45:01) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.9, Copyright (c) 1998-2018 Zend Technologies
 ✝  ~  which php
/usr/bin/php
 ✝  ~  brew link --force [email protected]
Linking /usr/local/Cellar/[email protected]/7.2.25... 25 symlinks created

If you need to have this software first in your PATH instead consider running:
  echo 'export PATH="/usr/local/opt/[email protected]/bin:$PATH"' >> ~/.zshrc
  echo 'export PATH="/usr/local/opt/[email protected]/sbin:$PATH"' >> ~/.zshrc
 ✝  ~  echo 'export PATH="/usr/local/opt/[email protected]/bin:$PATH"' >> ~/.zshrc
 ✝  ~  echo 'export PATH="/usr/local/opt/[email protected]/sbin:$PATH"' >> ~/.zshrc
 ✝  ~  source ~/.zshrc
 ✝  ~  composer global update
Changed current directory to /Users/brianhogg/.composer
Loading composer repositories with package information
Updating dependencies (including require-dev)
Nothing to install or update
Generating autoload files
 ✝  ~  composer global require laravel/valet
Changed current directory to /Users/brianhogg/.composer
Using version ^2.5 for laravel/valet
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 9 installs, 0 updates, 0 removals
  - Installing symfony/var-dumper (v5.0.1): Loading from cache
  - Installing tightenco/collect (v6.5.2): Loading from cache
  - Installing nategood/httpful (0.2.20): Loading from cache
  - Installing php-di/invoker (2.0.0): Loading from cache
  - Installing mnapoli/silly (1.7.2): Loading from cache
  - Installing psr/simple-cache (1.0.1): Loading from cache
  - Installing illuminate/contracts (v6.6.2): Loading from cache
  - Installing illuminate/container (v6.6.2): Loading from cache
  - Installing laravel/valet (v2.5.4): Loading from cache
Writing lock file
Generating autoload files
 ✝  ~  valet install
Password:
Stopping nginx...
Installing nginx configuration...
Installing nginx directory...
Updating PHP configuration...

Warning: file_get_contents(/usr/local/etc/php/7.2/php-fpm.d/www.conf): failed to open stream: No such file or directory in /Users/brianhogg/.composer/vendor/laravel/valet/cli/Valet/Filesystem.php on line 112

Warning: file_put_contents(/usr/local/etc/php/7.2/php-fpm.d/www.conf): failed to open stream: No such file or directory in /Users/brianhogg/.composer/vendor/laravel/valet/cli/Valet/Filesystem.php on line 125
Restarting [email protected]...
Restarting dnsmasq...
Valet is configured to serve for TLD [.test]
Restarting nginx...

Valet installed successfully!
 ✝  ~ 

And still the same error. There must be a configuration still being used somewhere but from only the valet.sock error in the valet nginx log, and a successful valet install, I'm not seeing how to get it sorted. There's also the warning during install that points to it still using what looks like the system version of php-fpm.

Output of the remaining commands along with editing the config to have

include=/usr/local/Cellar/[email protected]/7.2.25/.bottle/etc/php/7.2/php-fpm.d/*.conf at the end:

✝  ~  sw_vers
ProductName:	Mac OS X
ProductVersion:	10.15.1
BuildVersion:	19B88
 ✝  ~  valet --version
Password:
Laravel Valet 2.5.4
 ✝  ~  cat ~/.config/valet/config.json
{
    "tld": "test",
    "paths": []
}
 ✝  ~  ls -la /etc/sudoers.d/
total 0
drwxr-xr-x    2 root  wheel    64 24 Aug 18:58 .
drwxr-xr-x  117 root  wheel  3744  5 Dec 12:20 ..
 ✝  ~  openssl versio n-a
openssl:Error: 'versio' is an invalid command.

Standard commands
asn1parse         ca                certhash          ciphers
crl               crl2pkcs7         dgst              dh
dhparam           dsa               dsaparam          ec
ecparam           enc               errstr            gendh
gendsa            genpkey           genrsa            nseq
ocsp              passwd            pkcs12            pkcs7
pkcs8             pkey              pkeyparam         pkeyutl
prime             rand              req               rsa
rsautl            s_client          s_server          s_time
sess_id           smime             speed             spkac
ts                verify            version           x509

Message Digest commands (see the `dgst' command for more details)
gost-mac          md4               md5               md_gost94
ripemd160         sha1              sha224            sha256
sha384            sha512            streebog256       streebog512
whirlpool

Cipher commands (see the `enc' command for more details)
aes-128-cbc       aes-128-ecb       aes-192-cbc       aes-192-ecb
aes-256-cbc       aes-256-ecb       base64            bf
bf-cbc            bf-cfb            bf-ecb            bf-ofb
camellia-128-cbc  camellia-128-ecb  camellia-192-cbc  camellia-192-ecb
camellia-256-cbc  camellia-256-ecb  cast              cast-cbc
cast5-cbc         cast5-cfb         cast5-ecb         cast5-ofb
chacha            des               des-cbc           des-cfb
des-ecb           des-ede           des-ede-cbc       des-ede-cfb
des-ede-ofb       des-ede3          des-ede3-cbc      des-ede3-cfb
des-ede3-ofb      des-ofb           des3              desx
rc2               rc2-40-cbc        rc2-64-cbc        rc2-cbc
rc2-cfb           rc2-ecb           rc2-ofb           rc4
rc4-40

 ✝  ~  openssl version -a
LibreSSL 2.8.3
built on: date not available
platform: information not available
options:  bn(64,64) rc4(16x,int) des(idx,cisc,16,int) blowfish(idx)
compiler: information not available
OPENSSLDIR: "/private/etc/ssl"
 ✝  ~  openssl ciphers
ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-CHACHA20-POLY1305:GOST2012256-GOST89-GOST89:DHE-RSA-CAMELLIA256-SHA256:DHE-RSA-CAMELLIA256-SHA:GOST2001-GOST89-GOST89:AES256-GCM-SHA384:AES256-SHA256:AES256-SHA:CAMELLIA256-SHA256:CAMELLIA256-SHA:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-CAMELLIA128-SHA256:DHE-RSA-CAMELLIA128-SHA:AES128-GCM-SHA256:AES128-SHA256:AES128-SHA:CAMELLIA128-SHA256:CAMELLIA128-SHA:ECDHE-RSA-RC4-SHA:ECDHE-ECDSA-RC4-SHA:RC4-SHA:RC4-MD5:ECDHE-RSA-DES-CBC3-SHA:ECDHE-ECDSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:DES-CBC3-SHA
 ✝  ~  php -v
PHP 7.2.25 (cli) (built: Nov 22 2019 10:27:28) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
 ✝  ~  which php
/usr/local/opt/[email protected]/bin/php
 ✝  ~  which -a php
/usr/local/opt/[email protected]/bin/php
/usr/local/bin/php
/usr/bin/php
 ✝  ~  nginx -v
nginx version: nginx/1.17.3
 ✝  ~  curl --version
curl 7.64.1 (x86_64-apple-darwin19.0) libcurl/7.64.1 (SecureTransport) LibreSSL/2.8.3 zlib/1.2.11 nghttp2/1.39.2
Release-Date: 2019-03-27
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp smb smbs smtp smtps telnet tftp
Features: AsynchDNS GSS-API HTTP2 HTTPS-proxy IPv6 Kerberos Largefile libz MultiSSL NTLM NTLM_WB SPNEGO SSL UnixSockets
 ✝  ~  php --ri curl

curl

cURL support => enabled
cURL Information => 7.67.0
Age => 5
Features
AsynchDNS => Yes
CharConv => No
Debug => No
GSS-Negotiate => No
IDN => No
IPv6 => Yes
krb4 => No
Largefile => Yes
libz => Yes
NTLM => Yes
NTLMWB => Yes
SPNEGO => Yes
SSL => Yes
SSPI => No
TLS-SRP => Yes
HTTP2 => Yes
GSSAPI => Yes
KERBEROS5 => Yes
UNIX_SOCKETS => Yes
PSL => No
Protocols => dict, file, ftp, ftps, gopher, http, https, imap, imaps, ldap, ldaps, pop3, pop3s, rtmp, rtsp, scp, sftp, smb, smbs, smtp, smtps, telnet, tftp
Host => x86_64-apple-darwin19.0.0
SSL Version => OpenSSL/1.1.1d
ZLib Version => 1.2.11
libSSH Version => libssh2/1.9.0
 ✝  ~  brew config
HOMEBREW_VERSION: 2.2.0
ORIGIN: https://github.com/Homebrew/brew
HEAD: 7d7de295dfbc5e581106e2b1f674496b5e25a773
Last commit: 8 days ago
Core tap ORIGIN: https://github.com/Homebrew/homebrew-core
Core tap HEAD: 70ee7daeb9b6c8c82eee6edb2204a88f9b174820
Core tap last commit: 4 hours ago
HOMEBREW_PREFIX: /usr/local
CPU: quad-core 64-bit skylake
Homebrew Ruby: 2.6.3 => /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby
Clang: 11.0 build 1100
Git: 2.24.0 => /usr/local/bin/git
Curl: 7.64.1 => /usr/bin/curl
Java: 1.8.0_152
macOS: 10.15.1-x86_64
CLT: 1100.0.33.12
Xcode: 11.2.1
 ✝  ~  brew doctor
Your system is ready to brew.
 ✝  ~  brew info openssl
[email protected]: stable 1.1.1d (bottled) [keg-only]
Cryptography and SSL/TLS Toolkit
https://openssl.org/
/usr/local/Cellar/[email protected]/1.1.1d (7,983 files, 17.9MB)
  Poured from bottle on 2019-12-05 at 09:44:04
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/[email protected]
==> Caveats
A CA file has been bootstrapped using certificates from the system
keychain. To add additional certificates, place .pem files in
  /usr/local/etc/[email protected]/certs

and run
  /usr/local/opt/[email protected]/bin/c_rehash

[email protected] is keg-only, which means it was not symlinked into /usr/local,
because openssl/libressl is provided by macOS so don't link an incompatible version.

If you need to have [email protected] first in your PATH run:
  echo 'export PATH="/usr/local/opt/[email protected]/bin:$PATH"' >> ~/.zshrc

For compilers to find [email protected] you may need to set:
  export LDFLAGS="-L/usr/local/opt/[email protected]/lib"
  export CPPFLAGS="-I/usr/local/opt/[email protected]/include"

For pkg-config to find [email protected] you may need to set:
  export PKG_CONFIG_PATH="/usr/local/opt/[email protected]/lib/pkgconfig"

==> Analytics
install: 512,343 (30 days), 1,834,748 (90 days), 2,399,702 (365 days)
install-on-request: 56,969 (30 days), 153,444 (90 days), 426,205 (365 days)
build-error: 0 (30 days)
 ✝  ~  brew info nginx
nginx: stable 1.17.3 (bottled), HEAD
HTTP(S) server and reverse proxy, and IMAP/POP3 proxy server
https://nginx.org/
/usr/local/Cellar/nginx/1.17.3_1 (25 files, 2MB) *
  Poured from bottle on 2019-12-05 at 13:52:50
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/nginx.rb
==> Dependencies
Required: [email protected] ✔, pcre ✔
==> Options
--HEAD
	Install HEAD version
==> Caveats
Docroot is: /usr/local/var/www

The default port has been set in /usr/local/etc/nginx/nginx.conf to 8080 so that
nginx can run without sudo.

nginx will load all files in /usr/local/etc/nginx/servers/.

To have launchd start nginx now and restart at login:
  brew services start nginx
Or, if you don't want/need a background service you can just run:
  nginx
==> Analytics
install: 26,999 (30 days), 80,964 (90 days), 401,887 (365 days)
install-on-request: 26,388 (30 days), 78,668 (90 days), 381,595 (365 days)
build-error: 0 (30 days)
 ✝  ~  brew info php
php: stable 7.4.0 (bottled)
General-purpose scripting language
https://www.php.net/
Not installed
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/php.rb
==> Dependencies
Build: httpd ✔, pkg-config ✔
Required: apr ✔, apr-util ✔, argon2 ✔, aspell ✔, autoconf ✔, curl-openssl ✔, freetds ✔, freetype ✔, gettext ✔, glib ✔, gmp ✔, icu4c ✔, jpeg ✔, libffi ✔, libpng ✔, libpq ✔, libsodium ✔, libzip ✔, oniguruma ✔, openldap ✔, [email protected] ✔, sqlite ✔, tidy-html5 ✔, unixodbc ✔, webp ✔
==> Caveats
To enable PHP in Apache add the following to httpd.conf and restart Apache:
    LoadModule php7_module /usr/local/opt/php/lib/httpd/modules/libphp7.so

    <FilesMatch \.php$>
        SetHandler application/x-httpd-php
    </FilesMatch>

Finally, check DirectoryIndex includes index.php
    DirectoryIndex index.php index.html

The php.ini and php-fpm.ini file can be found in:
    /usr/local/etc/php/7.4/

To have launchd start php now and restart at login:
  brew services start php
Or, if you don't want/need a background service you can just run:
  php-fpm
==> Analytics
install: 48,867 (30 days), 134,446 (90 days), 462,617 (365 days)
install-on-request: 45,669 (30 days), 125,063 (90 days), 422,572 (365 days)
build-error: 0 (30 days)
 ✝  ~  brew info [email protected]
[email protected]: stable 7.2.25 (bottled) [keg-only]
General-purpose scripting language
https://www.php.net/
/usr/local/Cellar/[email protected]/7.2.25 (514 files, 74.8MB) *
  Poured from bottle on 2019-12-05 at 13:53:17
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/[email protected]
==> Dependencies
Build: httpd ✔, pkg-config ✔
Required: apr ✔, apr-util ✔, argon2 ✔, aspell ✔, autoconf ✔, curl-openssl ✔, freetds ✔, freetype ✔, gettext ✔, glib ✔, gmp ✔, icu4c ✔, jpeg ✔, libpng ✔, libpq ✔, libsodium ✔, libzip ✔, openldap ✔, [email protected] ✔, sqlite ✔, tidy-html5 ✔, unixodbc ✔, webp ✔
==> Caveats
To enable PHP in Apache add the following to httpd.conf and restart Apache:
    LoadModule php7_module /usr/local/opt/[email protected]/lib/httpd/modules/libphp7.so

    <FilesMatch \.php$>
        SetHandler application/x-httpd-php
    </FilesMatch>

Finally, check DirectoryIndex includes index.php
    DirectoryIndex index.php index.html

The php.ini and php-fpm.ini file can be found in:
    /usr/local/etc/php/7.2/

[email protected] is keg-only, which means it was not symlinked into /usr/local,
because this is an alternate version of another formula.

If you need to have [email protected] first in your PATH run:
  echo 'export PATH="/usr/local/opt/[email protected]/bin:$PATH"' >> ~/.zshrc
  echo 'export PATH="/usr/local/opt/[email protected]/sbin:$PATH"' >> ~/.zshrc

For compilers to find [email protected] you may need to set:
  export LDFLAGS="-L/usr/local/opt/[email protected]/lib"
  export CPPFLAGS="-I/usr/local/opt/[email protected]/include"


To have launchd start [email protected] now and restart at login:
  brew services start [email protected]
Or, if you don't want/need a background service you can just run:
  php-fpm
; - port       (Solaris >= 10)
==> Analytics
install: 17,557 (30 days), 55,421 (90 days), 207,334 (365 days)
install-on-request: 17,370 (30 days), 54,877 (90 days), 205,307 (365 days)
build-error: 0 (30 days)
 ✝  ~  php-fpm
[05-Dec-2019 14:13:40] WARNING: Nothing matches the include pattern '/usr/local/etc/php/7.2/php-fpm.d/*.conf' from /usr/local/etc/php/7.2/php-fpm.conf at line 105.
[05-Dec-2019 14:13:40] ERROR: No pool defined. at least one pool section must be specified in config file
[05-Dec-2019 14:13:40] ERROR: failed to post process the configuration
[05-Dec-2019 14:13:40] ERROR: FPM initialization failed
 ✘ ✝  ~  ~/.composer/vendor/laravel/valet/bin/ngrok version
ngrok version 2.3.34
 ✝  ~  ls -la ~/.ngrok2
ls: /Users/brianhogg/.ngrok2: No such file or directory
 ✘ ✝  ~  sudo nginx -t
nginx: the configuration file /usr/local/etc/nginx/nginx.conf syntax is ok
nginx: configuration file /usr/local/etc/nginx/nginx.conf test is successful
 ✝  ~  which php-fpm
/usr/local/opt/[email protected]/sbin/php-fpm
 ✝  ~  which -a php-fpm
/usr/local/opt/[email protected]/sbin/php-fpm
/usr/local/Cellar/[email protected]/7.2.25/sbin/php-fpm
/usr/local/sbin/php-fpm
/usr/sbin/php-fpm
 ✝  ~  vim /usr/local/etc/php/7.2/php-fpm.conf
 ✝  ~  php-fpm
[05-Dec-2019 14:18:02] NOTICE: [pool www] 'user' directive is ignored when FPM is not running as root
[05-Dec-2019 14:18:02] NOTICE: [pool www] 'group' directive is ignored when FPM is not running as root
[05-Dec-2019 14:18:02] ERROR: unable to bind listening socket for address '127.0.0.1:9000': Address already in use (48)
[05-Dec-2019 14:18:02] ERROR: FPM initialization failed
 ✘ ✝  ~  valet restart
Password:
Restarting [email protected]...
Restarting nginx...
Valet services have been restarted.
 ✝  ~  php-fpm
[05-Dec-2019 14:19:08] NOTICE: [pool www] 'user' directive is ignored when FPM is not running as root
[05-Dec-2019 14:19:08] NOTICE: [pool www] 'group' directive is ignored when FPM is not running as root
[05-Dec-2019 14:19:08] ERROR: unable to bind listening socket for address '127.0.0.1:9000': Address already in use (48)
[05-Dec-2019 14:19:08] ERROR: FPM initialization failed
 ✘ ✝  ~  vim /usr/local/etc/php/7.2/php-fpm.conf
 ✝  ~  php-fpm -v
PHP 7.2.25 (fpm-fcgi) (built: Nov 22 2019 10:27:37)
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies

@brianhogg
Copy link
Author

So perhaps something above also might have helped, but the key was this warning during valet install:

Warning: file_get_contents(/usr/local/etc/php/7.2/php-fpm.d/www.conf): failed to open stream: No such file or directory in /Users/brianhogg/.composer/vendor/laravel/valet/cli/Valet/Filesystem.php on line 112

That folder didn't exist and it was trying to pull the configuration from it. So I did:

cd /usr/local/etc/php/7.2
sudo ln -s /usr/local/Cellar/[email protected]/7.2.25/.bottle/etc/php/7.2/php-fpm.d/ php-fpm.d
valet install

which gave no warnings and voila, sites load :)

@drbyte
Copy link
Contributor

drbyte commented Dec 5, 2019

Good work, and good catch on the missing directory.

I'm a little surprised that PHP didn't auto-create the php-fpm.d directory, but I'm glad you made one. You could have just used mkdir, rather than symlinking, as the contents are intended to be volatile.

I've an open PR that reworks how the FPM pool config is handled. I'll review it to make sure we create that directory if it's missing though, since that'll save some trouble in the future.

You can close this if it's resolved for you. Maybe also update the Title to mention something about @7.2 and Catalina?

@brianhogg brianhogg changed the title 502 Bad Gateway after installing valet 502 Bad Gateway after installing valet ([email protected], Catalina) Dec 5, 2019
@brianhogg
Copy link
Author

brianhogg commented Dec 5, 2019

Moral of the story is treat warnings during valet install as errors :)

Yes, just creating the folder works. You still get a warning when running valet install since the file_get_contents part fails, but the putting of the file succeeds and all seems well.

Marking as closed since it is working for me. Thanks for the help!

@brianhogg
Copy link
Author

brianhogg commented Feb 6, 2020

@drbyte FYI on the latest version of valet, I'm still getting the same error again when switching back to [email protected]:

✝  ~  valet use [email protected]
Password:
Unlinking current version: [email protected]
Linking new version: [email protected]
Updating PHP configuration...
Restarting [email protected]...
Restarting nginx...
Valet is now using [email protected].

Note that you might need to run composer global update if your PHP version change affects the dependencies of global packages required by Composer.
 ✝  ~  composer global update
Changed current directory to /Users/brianhogg/.composer
Loading composer repositories with package information
Updating dependencies (including require-dev)
Nothing to install or update
Generating autoload files
 ✝  ~  tail -f ~/.config/valet/Log/nginx-error.log
2020/02/06 11:23:21 [crit] 416#0: *72 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: "shortcode.test", referrer: "http://shortcode.test/shortcode"
^C
 ✘ ✝  ~  ls -la /usr/local/etc/php/7.2/php-fpm.d/
total 8
drwxr-xr-x  4 root  wheel  128  6 Feb 10:33 .
drwxr-xr-x  5 root  wheel  160  5 Dec 15:05 ..
-rw-r--r--  1 root  wheel  633  6 Feb 11:18 valet-fpm.conf
-rw-r--r--  1 root  wheel    0  6 Feb 10:18 www.conf-backup
 ✝  ~  cat /usr/local/etc/php/7.2/php-fpm.d/valet-fpm.conf
; FPM pool configuration for Valet

[valet]
user = brianhogg
group = staff
listen = /Users/brianhogg/.config/valet/valet.sock
listen.owner = brianhogg
listen.group = staff
listen.mode = 0777

;; When uncommented, the following values will take precedence over settings declared elsewhere
;php_admin_value[memory_limit] = 128M
;php_admin_value[upload_max_filesize] = 128M
;php_admin_value[post_max_size] = 128M

;php_admin_value[error_log] = /Users/brianhogg/.config/valet/Log/fpm-php.www.log
;php_admin_flag[log_errors] = on



pm = dynamic
pm.max_children = 5
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 3

 ✝  ~  cat /Users/brianhogg/.config/valet/Log/fpm-php.www.log
cat: /Users/brianhogg/.config/valet/Log/fpm-php.www.log: No such file or directory

Not sure why the valet.sock is not loading as there's no logs being generated elsewhere, that I can find.

@brianhogg brianhogg reopened this Feb 6, 2020
@brianhogg
Copy link
Author

So it looks like php-fpm is not starting automatically. Switched back to php 7.4, and running php-fpm manually gets valet working:

 ✝  ~  php-fpm
[06-Feb-2020 11:43:17] NOTICE: [pool valet] 'user' directive is ignored when FPM is not running as root
[06-Feb-2020 11:43:17] NOTICE: [pool valet] 'group' directive is ignored when FPM is not running as root
[06-Feb-2020 11:43:17] NOTICE: fpm is running, pid 48634
[06-Feb-2020 11:43:17] NOTICE: ready to handle connections

There's no errors or warnings with valet restart or valet install

@drbyte
Copy link
Contributor

drbyte commented Feb 6, 2020

Not sure why it didn't start up the new PHP. Maybe it didn't fully shut down the old PHP version properly before switching, which blocked the next one from starting? (if so, the logs would show it trying to start the same pool that's already running.)

@brianhogg
Copy link
Author

Possibly. I'm not sure the best way to check now that brew is updated and brew services list no longer works. launchctl shows this:

launchctl list | grep php
5594	0	com.apple.xpc.launchd.oneshot.0x10000004.phpstorm
-	78	[email protected]
-	78	[email protected]
-	78	[email protected]

After trying again to valet use [email protected] and doing a killall php-fpm then re-running, a phpInfo() on a site shows 7.4 yet php -v shows 7.2. Pretty odd :)

@drbyte
Copy link
Contributor

drbyte commented Feb 6, 2020

brew services list no longer works.

That's puzzling. Not sure why it would stop.

a phpInfo() on a site shows 7.4 yet php -v shows 7.2. Pretty odd :)

No, that's somewhat normal. Running php from a website runs php-fpm, which is a separate process from the command-line php. FPM runs from the fpm pools linked to nginx, and the CLI runs from whatever paths are linked in your shell session at the time of running it.

So, if it's still showing 7.4 from a website, then that indicates that the valet.sock is still fired up by the 7.4 FPM service that got started. And, nginx just reads whatever socket was started.

Your troubleshooting requires:

  • find out why 7.4 is running at all.
  • find out why 7.2 isn't starting up to replace it.

Your extra launchctl entries for PHP might be culprits. I note there's no 7.4 or unversioned php entry there, and that there's duplicate 7.2. Not sure if you expected the 7.1. I'm inclined to clean those up to prevent ambiguity. brew services stop xxxxxx would be a starting point, but then may need to be more aggressive with direct launchctl commands and/or removal of launchAgents and launchDaemons followed by a reboot.

@brianhogg
Copy link
Author

Thanks for all the notes! I'm not even able to run brew services at this point:

brew services stop php
Error: Unknown command: services

Updated Xcode, ran brew update-reset and it's now allowing brew services list to work. brew doctor still says that xcode tools are out of date even though there's no updates available.

I've removed the 7.1 entry from launchctl, will try a reboot and see if that helps any. If not, unless you have other suggestions, I'll likely try completely removing valet with the instructions provided by valet uninstall and try a fresh install from there.

@drbyte
Copy link
Contributor

drbyte commented Feb 6, 2020

If you want a thorough cleanup, running valet uninstall --force is pretty aggressive and mostly complete.
After that you might wanna run brew list and remove things that you don't really need.
And brew cleanup does some housekeeping.
brew services cleanup will remove unused services, at least as far as brew knows about.
As you've seen, brew doctor shows some additional info.

You might want to peek in the /usr/local/etc dir and perhaps rename the various PHP version directories so they're backed up but not in use.

You can check for other launched apps to be sure nothing unexpected is firing:

ls -al ~/Library/LaunchAgents
ls -al /Library/LaunchAgents
ls -al /Library/LaunchDaemons

After that a reboot should be much cleaner, and you could begin installing Valet again.

Those are some thoughts that might offer additional insights anyway.

@brianhogg
Copy link
Author

After a couple reboots I was hitting an error where the /usr/local/etc/php/7.2/php-fpm.conf config was pointing to 7.2.25 instead of 7.2.27 when running php-fpm manually. Updated the configuration, tried a valet restart, and now it's bound to port 9000 but still the same 502 Bad Gateway.

brew doctor now says php is an unlinked keg:

Warning: You have unlinked kegs in your Cellar.
Leaving kegs unlinked can lead to build-trouble and cause brews that depend on
those kegs to fail to run properly once built. Run `brew link` on these:
  python
  php

Despite no errors with valet restart or valet install.

Just putting the above in case there's something else a valet restart or install can check for to avoid the bad gateway, but at this point I'll try force uninstalling everything and see how that goes!

@brianhogg
Copy link
Author

brianhogg commented Feb 11, 2020

valet uninstall --force returns with an error:

Removing certificates for all Secured sites...
No sites to unsecure. You may list all servable sites or links by running valet parked or valet links.
Removing Nginx and configs...
Stopping nginx...
Removing Dnsmasq and configs...
Stopping dnsmasq...
Removing Valet configs and customizations...
Removing PHP versions and configs...

In Process.php line 424:

  The process has been signaled with signal "9".


uninstall [--force]

brew list shows things like [email protected], but running brew uninstall or brew remove of [email protected] errors with "no such keg" though the /usr/local/Cellar/[email protected] folder exists. Removed that empty folder to get rid of it from brew list.

Removed python@2 and mysql-utilities and did a brew cleanup.

Then brew services cleanup returned:

brew services cleanup
Warning: Service [email protected] not managed by `brew services` => skipping
Warning: Service [email protected] not managed by `brew services` => skipping
All user-space services OK, nothing cleaned...

Which is interesting that there's still [email protected] and 7.1 hanging around, possibly when I had valet+ installed. Ran:

rm ~/Library/LaunchAgents/[email protected]
rm ~/Library/LaunchAgents/[email protected]
rm ~/Library/LaunchAgents/homebrew.mxcl.nginx.plist
rm ~/Library/LaunchAgents/homebrew.mxcl.dnsmasq.plist
rm ~/Library/LaunchAgents/homebrew.mxcl.httpd.plist
rm ~/Library/LaunchAgents/homebrew.mxcl.redis.plist
rm ~/Library/LaunchAgents/org.virtualbox.vboxwebsrv.plist
sudo rm /Library/LaunchAgents/com.oracle.java.Java-Updater.plist
sudo rm /Library/LaunchDaemons/homebrew.mxcl.httpd.plist
sudo rm /Library/LaunchDaemons/homebrew.mxcl.mailhog.plist
sudo rm /Library/LaunchDaemons/homebrew.mxcl.php71.plist
sudo rm /Library/LaunchDaemons/[email protected]
sudo rm /Library/LaunchDaemons/[email protected]
sudo rm /Library/LaunchDaemons/homebrew.mxcl.redis.plist
sudo rm /Library/LaunchDaemons/org.virtualbox.startup.plist
sudo rm /Library/LaunchDaemons/com.oracle.java.Helper-Tool.plist

to remove what valet should be managing or not needed at the moment. Will try a reboot and see if anything else lists with brew services cleanup

@brianhogg
Copy link
Author

Nothing came up after the above with a brew services cleanup, and running through the regular install steps afterwards worked successfully.

However a valet use [email protected] fails with:

valet use [email protected]
Stopping php...
Installing [email protected]...
[[email protected]] is not installed, installing it now via Brew... 🍻
==> Downloading https://homebrew.bintray.com/bottles/[email protected]
Already downloaded: /Users/brianhogg/Library/Caches/Homebrew/downloads/ba48e9cc411fe2add7e258b89e41f1e1ea885ac833e50ecdd32b5682aac86019--php@7.2-7.2.27.catalina.bottle.tar.gz
==> Pouring [email protected]
Warning: The post-install step did not complete successfully
You can try again using `brew postinstall [email protected]`
==> Caveats
To enable PHP in Apache add the following to httpd.conf and restart Apache:
    LoadModule php7_module /usr/local/opt/[email protected]/lib/httpd/modules/libphp7.so

    <FilesMatch \.php$>
        SetHandler application/x-httpd-php
    </FilesMatch>

Finally, check DirectoryIndex includes index.php
    DirectoryIndex index.php index.html

The php.ini and php-fpm.ini file can be found in:
    /usr/local/etc/php/7.2/

[email protected] is keg-only, which means it was not symlinked into /usr/local,
because this is an alternate version of another formula.

If you need to have [email protected] first in your PATH run:
  echo 'export PATH="/usr/local/opt/[email protected]/bin:$PATH"' >> ~/.zshrc
  echo 'export PATH="/usr/local/opt/[email protected]/sbin:$PATH"' >> ~/.zshrc

For compilers to find [email protected] you may need to set:
  export LDFLAGS="-L/usr/local/opt/[email protected]/lib"
  export CPPFLAGS="-I/usr/local/opt/[email protected]/include"


To have launchd start [email protected] now and restart at login:
  brew services start [email protected]
Or, if you don't want/need a background service you can just run:
  php-fpm
==> Summary
🍺  /usr/local/Cellar/[email protected]/7.2.27: 514 files, 74.8MB


In Brew.php line 140:

  Brew was unable to install [[email protected]].


use <phpVersion>

Running brew postinstall [email protected] still fails with no real description as to why:

brew postinstall [email protected]
==> Postinstalling [email protected]
Warning: The post-install step did not complete successfully
You can try again using `brew postinstall [email protected]`

While brew services start [email protected] succeeds, there's still the valet.sock error when trying to access the site. Tried running composer global update but no effect. Running valet use php sets it back to php 7.4 which works, just not for sites that still need to be upgraded.

@drbyte
Copy link
Contributor

drbyte commented Feb 11, 2020

Running brew postinstall [email protected] still fails with no real description as to why:

You might try combinations of additional flags to that command, like --verbose or --debug or --force, to see what they expose for you.

@brianhogg
Copy link
Author

brianhogg commented Feb 12, 2020

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

brew postinstall [email protected] --debug
/usr/local/Homebrew/Library/Homebrew/brew.rb (Formulary::FormulaLoader): loading /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/[email protected]
==> Postinstalling [email protected]
Warning: The post-install step did not complete successfully
You can try again using `brew postinstall [email protected]`
==> 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 [email protected] now completes without error, I still get the same valet.sock error in the nginx logs.

I've uninstalled [email protected] with brew uninstall [email protected] and will try blowing away all the non-7.4 configs, rebooting, and re-trying valet use [email protected]. Fingers crossed :)

@brianhogg
Copy link
Author

Success! Rebooted after ensuring the /usr/local/etc/php configs were fully removed, ran valet use [email protected] 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.

@drbyte
Copy link
Contributor

drbyte commented Feb 12, 2020

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" ?

@brianhogg brianhogg changed the title 502 Bad Gateway after installing valet ([email protected], Catalina) PHP 7.2 won't start. Warning: The post-install step did not complete successfully ([email protected], Catalina) Feb 18, 2020
@brianhogg
Copy link
Author

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

@pokhiii
Copy link

pokhiii commented Jul 21, 2020

Having the same problem can someone help?

2020/07/21 19:15:21 [crit] 37813#0: *1 connect() to unix:/Users/abhishekpokhriyal/.config/valet/valet.sock failed (2: No such file or directory) while connecting to upstream, client: 127.0.0.1, server: wordpress-one.test, request: "GET / HTTP/2.0", upstream: "fastcgi://unix:/Users/abhishekpokhriyal/.config/valet/valet.sock:", host: "wordpress-one.test"
2020/07/21 19:15:21 [crit] 37813#0: *1 connect() to unix:/Users/abhishekpokhriyal/.config/valet/valet.sock failed (2: No such file or directory) while connecting to upstream, client: 127.0.0.1, server: wordpress-one.test, request: "GET /favicon.ico HTTP/2.0", upstream: "fastcgi://unix:/Users/abhishekpokhriyal/.config/valet/valet.sock:", host: "wordpress-one.test", referrer: "https://wordpress-one.test/"

I upgraded the PHP version from 7.2 to 7.4 today.

@pokhiii
Copy link

pokhiii commented Jul 21, 2020

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.

@ragulka
Copy link

ragulka commented Jan 20, 2021

FWIW, I had the same exact issue when trying to upgrade to PHP 8. It did not help that I looked at the wrong php-fpm.log file... I was looking in ~/.config/valet/Log, but it turned out that the correct one was in /usr/local/var/log/php-fpm.log

After I chased down the error in the log, I tried removing and reinstalling PHP when I also noticed the warning about post-install not completing successfully, which led me to the comment above. Used the same steps and now it works!

@madamadami
Copy link

@abhishek-pokhriyal you saved my day! For uncounted hours I was trying to find the reason why PHP 8.1 didn't work, but thanks to your hint to permission issues I got it working.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants