laravel / valet

A more enjoyable local development experience for Mac.
https://laravel.com/docs/valet
MIT License
2.5k stars 692 forks source link

Isolated sites throw 502 errors #1222

Closed jackmcdade closed 2 years ago

jackmcdade commented 2 years ago

Description:

After global composer updating Valet and reinstalling, I isolated a site and it throws 502 errors.

Steps To Reproduce:

Isolate a site to PHP 7.4, get a 404

Diagnosis

sw_vers
ProductName:   macOS
ProductVersion: 12.0.1
BuildVersion:   21A559
valet --version
Laravel Valet 3.0.0
cat ~/.config/valet/config.json
{
    "tld": "test",
    "loopback": "127.0.0.1",
    "paths": [
        "/Users/jack/Sites"
    ]
}
cat ~/.composer/composer.json
{
    "require": {
        "laravel/valet": "^3.0",
        "beyondcode/expose": "^2.0",
        "statamic/cli": "^2.1",
        "tightenco/takeout": "^1.8"
    }
}
composer global diagnose
Changed current directory to /Users/jack/.composer
Checking composer.json: WARNING
No license specified, it is recommended to do so. For closed-source software you may use "proprietary" as license.
Checking platform settings: OK
Checking git settings: OK
Checking http connectivity to packagist: OK
Checking https connectivity to packagist: OK
Checking github.com oauth access: OK
Checking disk free space: OK
Checking pubkeys: 
Tags Public Key Fingerprint: 57815BA2 7E54DC31 7ECC7CC5 573090D0  87719BA6 8F3BB723 4E5D42D0 84A14642
Dev Public Key Fingerprint: 4AC45767 E5EC2265 2F0C1167 CBBB8A2B  0C708369 153E328C AD90147D AFE50952
OK
Checking composer version: You are not running the latest stable version, run `composer self-update` to update (2.2.0 => 2.2.9)
Composer version: 2.2.0
PHP version: 8.0.16
PHP binary path: /opt/homebrew/Cellar/php@8.0/8.0.16_1/bin/php
OpenSSL version: OpenSSL 1.1.1m  14 Dec 2021
cURL version: 7.82.0 libz 1.2.11 ssl (SecureTransport) OpenSSL/1.1.1m
zip: extension present, unzip present, 7-Zip not available
composer global outdated
Changed current directory to /Users/jack/.composer
Info from https://repo.packagist.org: #StandWithUkraine
Legend:
! patch or minor release available - update recommended
~ major release available - update possible
beyondcode/expose    2.1.2   ! 2.2.0  Create public URLs for local sites through any firewall and VPN.
guzzlehttp/guzzle    7.4.1   ! 7.4.2  Guzzle is a PHP HTTP client library
guzzlehttp/psr7      1.8.3   ~ 2.2.1  PSR-7 message implementation that also provides common utility methods
illuminate/container v9.4.1  ! v9.6.0 The Illuminate Container package.
illuminate/contracts v9.4.1  ! v9.6.0 The Illuminate Contracts package.
tightenco/collect    v8.83.2 ~ v9.4.1 Collect - Illuminate Collections as a separate package.
tightenco/takeout    v1.8.13 ~ v2.0.4 Manage your dev dependencies with simple one-off Docker containers.
ls -al /etc/sudoers.d/
total 16
drwxr-xr-x   4 root  wheel   128 Nov 17 11:24 .
drwxr-xr-x  82 root  wheel  2624 Jan  6 11:18 ..
-rw-r--r--   1 root  wheel    83 Nov 17 11:24 brew
-rw-r--r--   1 root  wheel    86 Nov 17 11:24 valet
brew config
HOMEBREW_VERSION: 3.4.4
ORIGIN: https://github.com/Homebrew/brew
HEAD: 5f5af43244eaece1f09d695603e1a261676713a0
Last commit: 3 days ago
Core tap ORIGIN: https://github.com/Homebrew/homebrew-core
Core tap HEAD: 1a87949d8b9fea9ca5688e27a9695a44c081c4df
Core tap last commit: 28 minutes ago
Core tap branch: master
HOMEBREW_PREFIX: /opt/homebrew
HOMEBREW_CASK_OPTS: []
HOMEBREW_CORE_GIT_REMOTE: https://github.com/Homebrew/homebrew-core
HOMEBREW_MAKE_JOBS: 10
Homebrew Ruby: 2.6.8 => /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby
CPU: 10-core 64-bit arm_firestorm_icestorm
Clang: 13.0.0 build 1300
Git: 2.32.0 => /Library/Developer/CommandLineTools/usr/bin/git
Curl: 7.77.0 => /usr/bin/curl
macOS: 12.0.1-arm64
CLT: 13.2.0.0.1.1638488800
Xcode: N/A
Rosetta 2: false
brew services list
Name    Status User File
dnsmasq none            root 
httpd   none                 
nginx   none            root 
php     none                 
php@7.3 none                 
php@7.4 none            root 
php@8.0 none            root
brew list --formula --versions | grep -E "(php|nginx|dnsmasq|mariadb|mysql|mailhog|openssl)(@\d\..*)?\s"
dnsmasq 2.86
nginx 1.21.4 1.21.6
openssl@1.1 1.1.1m
php 8.0.12 8.1.3_1 8.1.0.reinstall 8.1.3
php@7.3 7.3.33_2
php@7.4 7.4.25.reinstall 7.4.28.reinstall 7.4.28 7.4.25 7.4.26_1.reinstall
php@8.0 8.0.16_1 8.0.16
brew outdated
aom
ca-certificates
colordiff
glib
httpd
imagemagick
krb5
libomp
libtool
nginx
openssl@1.1
php
php@8.0
python@3.9
sqlite
wget
blender
phpmon
brew tap
homebrew/cask
homebrew/core
homebrew/services
nicoverbruggen/cask
shivammathur/php
php -v
PHP 8.0.16 (cli) (built: Feb 28 2022 07:39:12) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.16, Copyright (c) Zend Technologies
    with Zend OPcache v8.0.16, Copyright (c), by Zend Technologies
which -a php
/opt/homebrew/bin/php
php --ini
Configuration File (php.ini) Path: /opt/homebrew/etc/php/8.0
Loaded Configuration File:         /opt/homebrew/etc/php/8.0/php.ini
Scan for additional .ini files in: /opt/homebrew/etc/php/8.0/conf.d
Additional .ini files parsed:      /opt/homebrew/etc/php/8.0/conf.d/error_log.ini,
/opt/homebrew/etc/php/8.0/conf.d/ext-opcache.ini,
/opt/homebrew/etc/php/8.0/conf.d/php-memory-limits.ini
nginx -v
nginx version: nginx/1.21.6
curl --version
curl 7.77.0 (x86_64-apple-darwin21.0) libcurl/7.77.0 (SecureTransport) LibreSSL/2.8.3 zlib/1.2.11 nghttp2/1.42.0
Release-Date: 2021-05-26
Protocols: dict file ftp ftps gopher gophers http https imap imaps ldap ldaps mqtt pop3 pop3s rtsp smb smbs smtp smtps telnet tftp 
Features: alt-svc AsynchDNS GSS-API HSTS HTTP2 HTTPS-proxy IPv6 Kerberos Largefile libz MultiSSL NTLM NTLM_WB SPNEGO SSL UnixSockets
php --ri curl
curl

cURL support => enabled
cURL Information => 7.82.0
Age => 9
Features
AsynchDNS => Yes
CharConv => No
Debug => No
GSS-Negotiate => No
IDN => Yes
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
HTTPS_PROXY => Yes
MULTI_SSL => Yes
BROTLI => Yes
Protocols => dict, file, ftp, ftps, gopher, gophers, http, https, imap, imaps, ldap, ldaps, mqtt, pop3, pop3s, rtmp, rtsp, scp, sftp, smb, smbs, smtp, smtps, telnet, tftp
Host => aarch64-apple-darwin21.3.0
SSL Version => (SecureTransport) OpenSSL/1.1.1m
ZLib Version => 1.2.11
libSSH Version => libssh2/1.10.0

Directive => Local Value => Master Value
curl.cainfo => no value => no value
~/.composer/vendor/laravel/valet/bin/ngrok version
ngrok version 2.3.40
~/.composer/vendor/laravel/valet/bin/ngrok-arm version
ngrok version 2.3.40
ls -al ~/.ngrok2
ls: /Users/jack/.ngrok2: No such file or directory
brew info nginx
nginx: stable 1.21.6 (bottled), HEAD
HTTP(S) server and reverse proxy, and IMAP/POP3 proxy server
https://nginx.org/
/opt/homebrew/Cellar/nginx/1.21.4 (23 files, 2.2MB)
  Built from source
/opt/homebrew/Cellar/nginx/1.21.6 (26 files, 2.2MB) *
  Poured from bottle on 2022-02-22 at 08:38:35
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/nginx.rb
License: BSD-2-Clause
==> Dependencies
Required: openssl@1.1, pcre2
==> Options
--HEAD
    Install HEAD version
==> Caveats
Docroot is: /opt/homebrew/var/www

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

nginx will load all files in /opt/homebrew/etc/nginx/servers/.

To restart nginx after an upgrade:
  brew services restart nginx
Or, if you don't want/need a background service you can just run:
  /opt/homebrew/opt/nginx/bin/nginx -g daemon off;
==> Analytics
install: 44,558 (30 days), 124,874 (90 days), 491,587 (365 days)
install-on-request: 44,477 (30 days), 124,658 (90 days), 490,562 (365 days)
build-error: 14 (30 days)
brew info php
php: stable 8.1.4 (bottled), HEAD
General-purpose scripting language
https://www.php.net/
/opt/homebrew/Cellar/php/8.0.12 (498 files, 78.0MB)
  Built from source
/opt/homebrew/Cellar/php/8.1.0.reinstall (193 files, 33.6MB)
  Built from source
/opt/homebrew/Cellar/php/8.1.3 (505 files, 81.3MB)
  Built from source
/opt/homebrew/Cellar/php/8.1.3_1 (514 files, 81.6MB)
  Poured from bottle on 2022-03-07 at 15:13:30
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/php.rb
License: PHP-3.01
==> Dependencies
Build: httpd, pkg-config
Required: apr, apr-util, argon2, aspell, autoconf, curl, freetds, gd, gettext, gmp, icu4c, krb5, libpq, libsodium, libzip, oniguruma, openldap, openssl@1.1, pcre2, sqlite, tidy-html5, unixodbc
==> Options
--HEAD
    Install HEAD version
==> Caveats
To enable PHP in Apache add the following to httpd.conf and restart Apache:
    LoadModule php_module /opt/homebrew/opt/php/lib/httpd/modules/libphp.so

    
        SetHandler application/x-httpd-php
    

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

The php.ini and php-fpm.ini file can be found in:
    /opt/homebrew/etc/php/8.1/

To restart php after an upgrade:
  brew services restart php
Or, if you don't want/need a background service you can just run:
  /opt/homebrew/opt/php/sbin/php-fpm --nodaemonize
==> Analytics
install: 143,475 (30 days), 367,261 (90 days), 955,372 (365 days)
install-on-request: 120,668 (30 days), 303,206 (90 days), 838,098 (365 days)
build-error: 56 (30 days)
brew info openssl
openssl@3: stable 3.0.2 (bottled) [keg-only]
Cryptography and SSL/TLS Toolkit
https://openssl.org/
Not installed
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/openssl@3.rb
License: Apache-2.0
==> Dependencies
Required: ca-certificates
==> Caveats
A CA file has been bootstrapped using certificates from the system
keychain. To add additional certificates, place .pem files in
  /opt/homebrew/etc/openssl@3/certs

and run
  /opt/homebrew/opt/openssl@3/bin/c_rehash

openssl@3 is keg-only, which means it was not symlinked into /opt/homebrew,
because macOS provides LibreSSL.

==> Analytics
install: 142,777 (30 days), 348,974 (90 days), 645,971 (365 days)
install-on-request: 112,185 (30 days), 269,804 (90 days), 505,742 (365 days)
build-error: 5,450 (30 days)
openssl version -a
LibreSSL 2.8.3
built on: date not available
platform: information not available
options:  bn(64,64) rc4(ptr,int) des(idx,cisc,16,int) blowfish(idx) 
compiler: information not available
OPENSSLDIR: "/private/etc/ssl"
openssl ciphers
ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-CHACHA20-POLY1305: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: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
sudo nginx -t
nginx: the configuration file /opt/homebrew/etc/nginx/nginx.conf syntax is ok
nginx: configuration file /opt/homebrew/etc/nginx/nginx.conf test is successful
which -a php-fpm
/opt/homebrew/sbin/php-fpm
/opt/homebrew/opt/php/sbin/php-fpm -v
PHP 8.1.3 (fpm-fcgi) (built: Feb 28 2022 07:27:39)
Copyright (c) The PHP Group
Zend Engine v4.1.3, Copyright (c) Zend Technologies
    with Zend OPcache v8.1.3, Copyright (c), by Zend Technologies
sudo /opt/homebrew/opt/php/sbin/php-fpm -y /opt/homebrew/etc/php/8.0/php-fpm.conf --test
[29-Mar-2022 13:42:52] NOTICE: configuration file /opt/homebrew/etc/php/8.0/php-fpm.conf test is successful
ls -al ~/Library/LaunchAgents | grep homebrew

ls -al /Library/LaunchAgents | grep homebrew

ls -al /Library/LaunchDaemons | grep homebrew
-rw-r--r--   1 root  admin   602 Mar 29 13:13 homebrew.mxcl.dnsmasq.plist
-rw-r--r--   1 root  admin   490 Mar 29 13:20 homebrew.mxcl.nginx.plist
-rw-r--r--   1 root  admin   594 Mar 29 13:20 homebrew.mxcl.php@7.4.plist
-rw-r--r--   1 root  admin   594 Mar 29 13:13 homebrew.mxcl.php@8.0.plist
ls -al /Library/LaunchDaemons | grep "com.laravel.valet."

ls -aln /etc/resolv.conf
lrwxr-xr-x  1 0  0  22 Oct 17 23:30 /etc/resolv.conf -> ../var/run/resolv.conf
cat /etc/resolv.conf
#
# macOS Notice
#
# This file is not consulted for DNS hostname resolution, address
# resolution, or the DNS query routing mechanism used by most
# processes on this system.
#
# To view the DNS configuration used by this system, use:
#   scutil --dns
#
# SEE ALSO
#   dns-sd(1), scutil(8)
#
# This file is automatically generated.
#
search lan
nameserver 8.8.8.8
ifconfig lo0
lo0: flags=8049 mtu 16384
    options=1203
    inet 127.0.0.1 netmask 0xff000000 
    inet6 ::1 prefixlen 128 
    inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1 
    nd6 options=201
sh -c 'echo "------\n/opt/homebrew/etc/nginx/valet/valet.conf\n---\n"; cat /opt/homebrew/etc/nginx/valet/valet.conf | grep -n "# valet loopback"; echo "\n------\n"'
------
/opt/homebrew/etc/nginx/valet/valet.conf
---

3:    #listen VALET_LOOPBACK:80; # valet loopback

------
sh -c 'for file in ~/.config/valet/dnsmasq.d/*; do echo "------\n~/.config/valet/dnsmasq.d/$(basename $file)\n---\n"; cat $file; echo "\n------\n"; done'
------
~/.config/valet/dnsmasq.d/tld-test.conf
---

address=/.test/127.0.0.1
listen-address=127.0.0.1

------
sh -c 'for file in ~/.config/valet/nginx/*; do echo "------\n~/.config/valet/nginx/$(basename $file)\n---\n"; cat $file | grep -n "# valet loopback"; echo "\n------\n"; done'
------
~/.config/valet/nginx/Oopla.test
---

3:    #listen 127.0.0.1:80; # valet loopback
10:    #listen 127.0.0.1:443 ssl http2; # valet loopback
54:    #listen 127.0.0.1:60; # valet loopback

------

------
~/.config/valet/nginx/getaway.test
---

3:    #listen 127.0.0.1:80; # valet loopback
10:    #listen 127.0.0.1:443 ssl http2; # valet loopback
54:    #listen 127.0.0.1:60; # valet loopback

------

------
~/.config/valet/nginx/statamic.com.test
---

5:    #listen VALET_LOOPBACK:80; # valet loopback

------

------
~/.config/valet/nginx/tour.test
---

3:    #listen 127.0.0.1:80; # valet loopback
10:    #listen 127.0.0.1:443 ssl http2; # valet loopback
54:    #listen 127.0.0.1:60; # valet loopback

------
NasirNobin commented 2 years ago

Diagnosis doesn't seem to have much info about the isolated sites. I assume we need to update the diagnosis command and add some info about isolated sites.

Here's how I would try to debug this:

  1. Running valet install (again) usually fixes these 502 errors.
    valet install
  2. If that doesn't fix it. I would try to reinstall that isolated PHP version manually.
    valet stop
    brew install shivammathur/php/php@7.4
    valet install

(These are very general steps, not sure if this will help)

jackmcdade commented 2 years ago

@NasirNobin Thanks for jumping in! Went through those steps and unfortunately the same result. If I unisolate it works fine, but re-isolating again and i'm in the same place.

jnbn commented 2 years ago

Same here...

Stopping nginx...
Installing nginx configuration...
Installing nginx directory...
Updating PHP configuration for php@8.1...
Restarting php@7.4...
Restarting php...
Updating Dnsmasq configuration...
Restarting dnsmasq...
Valet is configured to serve for TLD [.test]
Restarting nginx...

everything seems to be fine but getting .config/valet/valet74.sock` not found error on nginx.

jnbn commented 2 years ago

@jackmcdade Here's my solution:

brew reinstall php 7.4
sudo brew services restart php@7.4
sudo brew services // if php@7.4 is on that list it works.

I think it was a permission or ownership issue from the past.

mofman commented 2 years ago

@jackmcdade Here's my solution:

brew reinstall php 7.4
sudo brew services restart php@7.4
sudo brew services // if php@7.4 is on that list it works.

I think it was a permission or ownership issue from the past.

This worked for me - thankyou

mattstauffer commented 2 years ago

Jack and I paired and it was definitely permissions errors from previously installed versions of PHP.